Zelda Classic Coverage Report


Directory: src/
File: src/qst.cpp
Date: 2022-12-09 00:28:07
Exec Total Coverage
Lines: 6839 11443 59.8%
Functions: 66 105 62.9%
Branches: 4186 9897 42.3%

Line Branch Exec Source
1 //--------------------------------------------------------
2 // Zelda Classic
3 // by Jeremy Craner, 1999-2000
4 //
5 // qst.cc
6 //
7 // Code for loading '.qst' files in ZC and ZQuest.
8 //
9 //--------------------------------------------------------
10
11 #ifndef __GTHREAD_HIDE_WIN32API
12 #define __GTHREAD_HIDE_WIN32API 1
13 #endif //prevent indirectly including windows.h
14
15 #include "precompiled.h" //always first
16 9
17 #include <stdio.h>
18 #include <string.h>
19 #include <string>
20 #include <map>
21 #include <vector>
22 #include <assert.h>
23
24
25 #include "metadata/sigs/devsig.h.sig"
26 #include "metadata/sigs/compilersig.h.sig"
27 #include "metadata/versionsig.h"
28 #include "base/zc_alleg.h"
29 #include "base/zdefs.h"
30 #include "base/colors.h"
31 #include "tiles.h"
32 #include "base/zsys.h"
33 #include "qst.h"
34 //#include "zquest.h"
35 #include "defdata.h"
36 #include "subscr.h"
37 #include "font.h"
38 #include "zc_custom.h"
39 #include "sfx.h"
40 #include "md5.h"
41 #include "ffscript.h"
42 #include "particles.h"
43 #include "dialog/alert.h"
44 //FFScript FFCore;
45 extern FFScript FFCore;
46 extern ZModule zcm;
47 extern zcmodule moduledata;
48 extern uint8_t __isZQuest;
49 extern sprite_list guys, items, Ewpns, Lwpns, Sitems, chainlinks, decorations;
50 extern particle_list particles;
51 extern void setZScriptVersion(int32_t s_version);
52 //FFSCript FFEngine;
53
54 int32_t temp_ffscript_version = 0;
55 static bool read_ext_zinfo = false, read_zinfo = false;
56 static bool loadquest_report = false;
57 static char const* loading_qst_name = NULL;
58 static byte loading_qst_num = 0;
59
60 #ifdef _MSC_VER
61 #define strncasecmp _strnicmp
62 #endif
63
64 #ifndef _AL_MALLOC
65 #define _AL_MALLOC(a) _al_malloc(a)
66 #define _AL_FREE(a) _al_free(a)
67 #endif
68
69 using std::string;
70 using std::pair;
71
72 // extern bool debug;
73 extern int32_t hero_animation_speed; //lower is faster animation
74 extern std::vector<mapscr> TheMaps;
75 extern zcmap *ZCMaps;
76 extern MsgStr *MsgStrings;
77 extern DoorComboSet *DoorComboSets;
78 extern dmap *DMaps;
79 extern newcombo *combobuf;
80 extern byte *colordata;
81 //extern byte *tilebuf;
82 extern tiledata *newtilebuf;
83 extern byte *trashbuf;
84 extern itemdata *itemsbuf;
85 extern wpndata *wpnsbuf;
86 extern comboclass *combo_class_buf;
87 extern guydata *guysbuf;
88 extern ZCHEATS zcheats;
89 extern zinitdata zinit;
90 extern char palnames[MAXLEVELS][17];
91 extern int32_t memrequested;
92 extern char *byte_conversion(int32_t number, int32_t format);
93 extern char *byte_conversion2(int32_t number1, int32_t number2, int32_t format1, int32_t format2);
94 9 string zScript;
95 9 std::map<int32_t, script_slot_data > ffcmap;
96 9 std::map<int32_t, script_slot_data > globalmap;
97 9 std::map<int32_t, script_slot_data > genericmap;
98 9 std::map<int32_t, script_slot_data > itemmap;
99 9 std::map<int32_t, script_slot_data > npcmap;
100 9 std::map<int32_t, script_slot_data > ewpnmap;
101
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
18 std::map<int32_t, script_slot_data > lwpnmap;
102 9 std::map<int32_t, script_slot_data > playermap;
103 9 std::map<int32_t, script_slot_data > dmapmap;
104 9 std::map<int32_t, script_slot_data > screenmap;
105 9 std::map<int32_t, script_slot_data > itemspritemap;
106 9 std::map<int32_t, script_slot_data > comboscriptmap;
107 void free_newtilebuf();
108 bool combosread=false;
109 bool mapsread=false;
110 bool fixffcs=false;
111 bool fixpolsvoice=false;
112
113 9 const std::string script_slot_data::DEFAULT_FORMAT = "%s %s";
114 9 const std::string script_slot_data::INVALID_FORMAT = "%s --%s";
115 9 const std::string script_slot_data::DISASSEMBLED_FORMAT = "%s ++%s";
116 9 const std::string script_slot_data::ZASM_FORMAT = "%s ==%s";
117
118 char qstdat_string[2048] = { 0 };
119
120 static zinfo* load_tmp_zi = NULL;
121
122 int32_t memDBGwatch[8]= {0,0,0,0,0,0,0,0}; //So I can monitor memory crap
123 const byte clavio[9]={97,109,111,110,103,117,115,0};
124
125 //enum { qe_OK, qe_notfound, qe_invalid, qe_version, qe_obsolete,
126 // qe_missing, qe_internal, qe_pwd, qe_match, qe_minver };
127
128 extern combo_alias combo_aliases[MAXCOMBOALIASES];
129 extern combo_pool combo_pools[MAXCOMBOPOOLS];
130 const char *qst_error[] =
131 {
132 "OK","File not found","Invalid quest file",
133 "Version not supported","Obsolete version",
134 "Missing new data" , /* but let it pass in ZQuest */
135 "Internal error occurred", "Invalid password",
136 "Doesn't match saved game", "Save file is for older version of quest; please start new save",
137 "Out of memory", "File Debug Mode", "Canceled", "", "No quest assigned"
138 };
139
140 //for legacy quests -DD
141 enum { ssiBOMB, ssiSWORD, ssiSHIELD, ssiCANDLE, ssiLETTER, ssiPOTION, ssiLETTERPOTION, ssiBOW, ssiARROW, ssiBOWANDARROW, ssiBAIT, ssiRING, ssiBRACELET, ssiMAP,
142 ssiCOMPASS, ssiBOSSKEY, ssiMAGICKEY, ssiBRANG, ssiWAND, ssiRAFT, ssiLADDER, ssiWHISTLE, ssiBOOK, ssiWALLET, ssiSBOMB, ssiHCPIECE, ssiAMULET, ssiFLIPPERS,
143 ssiHOOKSHOT, ssiLENS, ssiHAMMER, ssiBOOTS, ssiDINSFIRE, ssiFARORESWIND, ssiNAYRUSLOVE, ssiQUIVER, ssiBOMBBAG, ssiCBYRNA, ssiROCS, ssiHOVERBOOTS,
144 ssiSPINSCROLL, ssiCROSSSCROLL, ssiQUAKESCROLL, ssiWHISPRING, ssiCHARGERING, ssiPERILSCROLL, ssiWEALTHMEDAL, ssiHEARTRING, ssiMAGICRING, ssiSPINSCROLL2,
145 ssiQUAKESCROLL2, ssiAGONY, ssiSTOMPBOOTS, ssiWHIMSICALRING, ssiPERILRING, ssiMAX
146 };
147
148 static byte deprecated_rules[QUESTRULES_NEW_SIZE];
149
150
151 void delete_combo_aliases()
152 {
153 for(int32_t j(0); j<256; j++)
154 {
155 if(combo_aliases[j].combos != NULL)
156 {
157 delete[] combo_aliases[j].combos;
158 combo_aliases[j].combos=NULL;
159 }
160
161 if(combo_aliases[j].csets != NULL)
162 {
163 delete[] combo_aliases[j].csets;
164 combo_aliases[j].csets=NULL;
165 }
166 }
167
168 }
169
170 char *byte_conversion(int32_t number, int32_t format)
171 {
172 static char num_str[40];
173
174 if(format==-1) //auto
175 {
176 format=1; //bytes
177
178 if(number>1024)
179 {
180 format=2; //kilobytes
181 }
182
183 if(number>1024*1024)
184 {
185 format=3; //megabytes
186 }
187
188 if(number>1024*1024*1024)
189 {
190 format=4; //gigabytes (dude, what are you doing?)
191 }
192 }
193
194 switch(format)
195 {
196 case 1: //bytes
197 sprintf(num_str,"%db",number);
198 break;
199
200 case 2: //kilobytes
201 sprintf(num_str,"%.2fk",float(number)/1024);
202 break;
203
204 case 3: //megabytes
205 sprintf(num_str,"%.2fM",float(number)/(1024*1024));
206 break;
207
208 case 4: //gigabytes
209 sprintf(num_str,"%.2fG",float(number)/(1024*1024*1024));
210 break;
211
212 default:
213 exit(1);
214 break;
215 }
216
217 return num_str;
218 }
219
220 126 char *byte_conversion2(int32_t number1, int32_t number2, int32_t format1, int32_t format2)
221 {
222 static char num_str1[40];
223 static char num_str2[40];
224 static char num_str[80];
225
226
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
126 if(format1==-1) //auto
227 {
228 126 format1=1; //bytes
229
230
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
126 if(number1>1024)
231 {
232 126 format1=2; //kilobytes
233 126 }
234
235
2/2
✓ Branch 0 taken 90 times.
✓ Branch 1 taken 36 times.
126 if(number1>1024*1024)
236 {
237 36 format1=3; //megabytes
238 36 }
239
240
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(number1>1024*1024*1024)
241 {
242 format1=4; //gigabytes (dude, what are you doing?)
243 }
244 126 }
245
246
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
126 if(format2==-1) //auto
247 {
248 126 format2=1; //bytes
249
250
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
126 if(number2>1024)
251 {
252 126 format2=2; //kilobytes
253 126 }
254
255
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 117 times.
126 if(number2>1024*1024)
256 {
257 117 format2=3; //megabytes
258 117 }
259
260
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(number2>1024*1024*1024)
261 {
262 format2=4; //gigabytes (dude, what are you doing?)
263 }
264 126 }
265
266
2/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 90 times.
✓ Branch 3 taken 36 times.
✗ Branch 4 not taken.
126 switch(format1)
267 {
268 case 1: //bytes
269 sprintf(num_str1,"%db",number1);
270 break;
271
272 case 2: //kilobytes
273 90 sprintf(num_str1,"%.2fk",float(number1)/1024);
274 90 break;
275
276 case 3: //megabytes
277 36 sprintf(num_str1,"%.2fM",float(number1)/(1024*1024));
278 36 break;
279
280 case 4: //gigabytes
281 sprintf(num_str1,"%.2fG",float(number1)/(1024*1024*1024));
282 break;
283
284 default:
285 exit(1);
286 break;
287 }
288
289
2/5
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 117 times.
✗ Branch 4 not taken.
126 switch(format2)
290 {
291 case 1: //bytes
292 sprintf(num_str2,"%db",number2);
293 break;
294
295 case 2: //kilobytes
296 9 sprintf(num_str2,"%.2fk",float(number2)/1024);
297 9 break;
298
299 case 3: //megabytes
300 117 sprintf(num_str2,"%.2fM",float(number2)/(1024*1024));
301 117 break;
302
303 case 4: //gigabytes
304 sprintf(num_str2,"%.2fG",float(number2)/(1024*1024*1024));
305 break;
306
307 default:
308 exit(1);
309 break;
310 }
311
312 126 sprintf(num_str, "%s/%s", num_str1, num_str2);
313 126 return num_str;
314 }
315
316 char *ordinal(int32_t num)
317 {
318 static const char *ending[4] = {"st","nd","rd","th"};
319 static char ord_str[8];
320
321 char *end;
322 int32_t t=(num%100)/10;
323 int32_t n=num%10;
324
325 if(n>=1 && n<4 && t!=1)
326 end = (char *)ending[n-1];
327 else
328 end = (char *)ending[3];
329
330 sprintf(ord_str,"%d%s",num%10000,end);
331 return ord_str;
332 }
333
334 9 int32_t get_version_and_build(PACKFILE *f, word *version, word *build)
335 {
336 int32_t ret;
337 9 *version=0;
338 9 *build=0;
339 9 byte temp_map_count=map_count;
340 byte temp_midi_flags[MIDIFLAGS_SIZE];
341 9 memcpy(temp_midi_flags, midi_flags, MIDIFLAGS_SIZE);
342
343 zquestheader tempheader;
344
345
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!f)
346 {
347 return qe_invalid;
348 }
349
350 9 ret=readheader(f, &tempheader, true);
351
352
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(ret)
353 {
354 return ret;
355 }
356
357 9 map_count=temp_map_count;
358 9 memcpy(midi_flags, temp_midi_flags, MIDIFLAGS_SIZE);
359 9 *version=tempheader.zelda_version;
360 9 *build=tempheader.build;
361 9 return 0;
362 9 }
363
364
365 9 bool find_section(PACKFILE *f, int32_t section_id_requested)
366 {
367
368
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!f)
369 {
370 return false;
371 }
372
373 int32_t section_id_read;
374 9 bool catchup=false;
375 word dummy;
376 byte tempbyte;
377 char tempbuf[65536];
378
379
380
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 switch(section_id_requested)
381 {
382 case ID_RULES:
383 case ID_STRINGS:
384 case ID_MISC:
385 case ID_TILES:
386 case ID_COMBOS:
387 case ID_CSETS:
388 case ID_MAPS:
389 case ID_DMAPS:
390 case ID_DOORS:
391 case ID_ITEMS:
392 case ID_WEAPONS:
393 case ID_COLORS:
394 case ID_ICONS:
395 case ID_INITDATA:
396 case ID_GUYS:
397 case ID_MIDIS:
398 case ID_CHEATS:
399 9 break;
400
401 default:
402 al_trace("Bad section requested!\n");
403 return false;
404 break;
405 }
406
407 dword section_size;
408
409 //section id
410
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_mgetl(&section_id_read,f,true))
411 {
412 return false;
413 }
414
415
1/2
✓ Branch 0 taken 1836 times.
✗ Branch 1 not taken.
1836 while(!pack_feof(f))
416 {
417
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 1827 times.
1836 switch(section_id_read)
418 {
419 case ID_RULES:
420 case ID_STRINGS:
421 case ID_MISC:
422 case ID_TILES:
423 case ID_COMBOS:
424 case ID_CSETS:
425 case ID_MAPS:
426 case ID_DMAPS:
427 case ID_DOORS:
428 case ID_ITEMS:
429 case ID_WEAPONS:
430 case ID_COLORS:
431 case ID_ICONS:
432 case ID_INITDATA:
433 case ID_GUYS:
434 case ID_MIDIS:
435 case ID_CHEATS:
436 9 catchup=false;
437 9 break;
438
439 default:
440 1827 break;
441 }
442
443
444
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1836 times.
1836 while(catchup)
445 {
446 //section id
447 section_id_read=(section_id_read<<8);
448
449 if(!p_getc(&tempbyte,f,true))
450 {
451 return false;
452 }
453
454 section_id_read+=tempbyte;
455 }
456
457
1/2
✓ Branch 0 taken 1836 times.
✗ Branch 1 not taken.
1836 if(section_id_read==section_id_requested)
458 {
459 return true;
460 }
461 else
462 {
463 //section version info
464
1/2
✓ Branch 0 taken 1836 times.
✗ Branch 1 not taken.
1836 if(!p_igetw(&dummy,f,true))
465 {
466 return false;
467 }
468
469
1/2
✓ Branch 0 taken 1836 times.
✗ Branch 1 not taken.
1836 if(!p_igetw(&dummy,f,true))
470 {
471 return false;
472 }
473
474 //section size
475
1/2
✓ Branch 0 taken 1836 times.
✗ Branch 1 not taken.
1836 if(!p_igetl(&section_size,f,true))
476 {
477 return false;
478 }
479
480 //pack_fseek(f, section_size);
481
2/2
✓ Branch 0 taken 589815 times.
✓ Branch 1 taken 1836 times.
591651 while(section_size>65535)
482 {
483 589815 pfread(tempbuf,65535,f,true);
484 589815 tempbuf[65535]=0;
485 589815 section_size-=65535;
486 }
487
488
2/2
✓ Branch 0 taken 1791 times.
✓ Branch 1 taken 45 times.
1836 if(section_size>0)
489 {
490 45 pfread(tempbuf,section_size,f,true);
491 45 tempbuf[section_size]=0;
492 45 }
493 }
494
495 //section id
496
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 1827 times.
1836 if(!p_mgetl(&section_id_read,f,true))
497 {
498 9 return false;
499 }
500 }
501
502 return false;
503 9 }
504
505
506
507
508
509 9 bool valid_zqt(PACKFILE *f)
510 {
511
512 //word tiles_used;
513 //word combos_used;
514 //open the file
515 //PACKFILE *f = pack_fopen(path, F_READ_PACKED);
516
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(!f)
517 return false;
518
519 //for now, everything else is valid
520 9 return true;
521
522 /*int16_t version;
523 byte build;
524
525 //read the version and make sure it worked
526 if(!p_igetw(&version,f,true))
527 {
528 goto error;
529 }
530
531 //read the build and make sure it worked
532 if(!p_getc(&build,f,true))
533 goto error;
534
535 //read the tile info and make sure it worked
536 if(!p_igetw(&tiles_used,f,true))
537 {
538 goto error;
539 }
540
541 for (int32_t i=0; i<tiles_used; i++)
542 {
543 if(!pfread(trashbuf,tilesize(tf4Bit),f,true))
544 {
545 goto error;
546 }
547 }
548
549 //read the combo info and make sure it worked
550 if(!p_igetw(&combos_used,f,true))
551 {
552 goto error;
553 }
554 for (int32_t i=0; i<combos_used; i++)
555 {
556 if(!pfread(trashbuf,sizeof(newcombo),f,true))
557 {
558 goto error;
559 }
560 }
561
562 //read the palette info and make sure it worked
563 for (int32_t i=0; i<48; i++)
564 {
565 if(!pfread(trashbuf,newpdTOTAL,f,true))
566 {
567 goto error;
568 }
569 }
570 if(!pfread(trashbuf,sizeof(palcycle)*256*3,f,true))
571 {
572 goto error;
573 }
574 for (int32_t i=0; i<MAXLEVELS; i++)
575 {
576 if(!pfread(trashbuf,PALNAMESIZE,f,true))
577 {
578 goto error;
579 }
580 }
581
582 //read the sprite info and make sure it worked
583 for (int32_t i=0; i<MAXITEMS; i++)
584 {
585 if(!pfread(trashbuf,sizeof(itemdata),f,true))
586 {
587 goto error;
588 }
589 }
590
591 for (int32_t i=0; i<MAXWPNS; i++)
592 {
593 if(!pfread(trashbuf,sizeof(wpndata),f,true))
594 {
595 goto error;
596 }
597 }
598
599 //read the triforce pieces info and make sure it worked
600 for (int32_t i=0; i<8; ++i)
601 {
602 if(!p_getc(&trashbuf,f,true))
603 {
604 goto error;
605 }
606 }
607
608
609
610 //read the game icons info and make sure it worked
611 for (int32_t i=0; i<4; ++i)
612 {
613 if(!p_igetw(&trashbuf,f,true))
614 {
615 goto error;
616 }
617 }
618
619 //read the misc colors info and map styles info and make sure it worked
620 if(!pfread(trashbuf,sizeof(zcolors),f,true))
621 {
622 goto error;
623 }
624
625 //read the template screens and make sure it worked
626 byte num_maps;
627 if(!p_getc(&num_maps,f,true))
628 {
629 goto error;
630 }
631 for (int32_t i=0; i<TEMPLATES; i++)
632 {
633 if(!pfread(trashbuf,sizeof(mapscr),f,true))
634 {
635 goto error;
636 }
637 }
638 if (num_maps>1) //dungeon templates
639 {
640 for (int32_t i=0; i<TEMPLATES; i++)
641 {
642 if(!pfread(trashbuf,sizeof(mapscr),f,true))
643 {
644 goto error;
645 }
646 }
647 }
648
649 //yay! it worked! close the file and say everything was ok.
650 pack_fclose(f);
651 return true;
652
653 error:
654 pack_fclose(f);
655 return false;*/
656 9 }
657
658 bool valid_zqt(const char *filename)
659 {
660 PACKFILE *f=NULL;
661 bool isvalid;
662 char deletefilename[1024];
663 deletefilename[0]=0;
664 int32_t error;
665 f=open_quest_file(&error, filename, deletefilename, true, true,false);
666
667 if(!f)
668 {
669 // setPackfilePassword(NULL);
670 return false;
671 }
672
673 isvalid=valid_zqt(f);
674
675 if(deletefilename[0])
676 {
677 delete_file(deletefilename);
678 }
679
680 // setPackfilePassword(NULL);
681 return isvalid;
682 }
683
684 67 PACKFILE *open_quest_file(int32_t *open_error, const char *filename, char *deletefilename, bool compressed,bool encrypted, bool show_progress)
685 {
686 char tmpfilename[L_tmpnam];
687 67 temp_name(tmpfilename);
688 char percent_done[30];
689 67 int32_t current_method=0;
690
691 PACKFILE *f;
692 67 const char *passwd= encrypted ? datapwd : "";
693
694 // oldquest flag is set when an unencrypted qst file is suspected.
695 67 bool oldquest = false;
696 int32_t ret;
697
698
1/2
✓ Branch 0 taken 67 times.
✗ Branch 1 not taken.
67 if(show_progress)
699 {
700 box_start(1, "Loading Quest", lfont, font, true);
701 }
702
703 67 box_out("Loading Quest: ");
704 //if(strncasecmp(filename, "qst.dat", 7)!=0)
705 //int32_t qstdat_str_size = 0;
706 //for ( int32_t q = 0; q < 255; q++ ) //find the length of the string
707 //{
708 // if ( moduledata.datafiles[qst_dat][q] != 0 ) qstdat_str_size++;
709 // else break;
710 //}
711 //if(strncasecmp(filename, moduledata.datafiles[qst_dat], 7)!=0)
712 67 al_trace("Trying to do strncasecmp() when loading a quest\n");
713 67 int32_t qstdat_filename_size = strlen(moduledata.datafiles[qst_dat]);
714 67 al_trace("Filename size of qst.dat file %s is %d.\n", moduledata.datafiles[qst_dat], qstdat_filename_size);
715 //if(strncasecmp(filename, moduledata.datafiles[qst_dat], qstdat_filename_size)!=0)
716
1/2
✓ Branch 0 taken 67 times.
✗ Branch 1 not taken.
67 if(strcmp(filename, moduledata.datafiles[qst_dat])!=0)
717 {
718 67 box_out(filename);
719 67 }
720 else
721 {
722 box_out("new quest"); // Or whatever
723 }
724 67 box_out("...");
725 67 box_eol();
726 67 box_eol();
727
728
1/2
✓ Branch 0 taken 67 times.
✗ Branch 1 not taken.
67 if(encrypted)
729 {
730 67 box_out("Decrypting...");
731 67 box_save_x();
732 67 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_MAX-1, strstr(filename, ".dat#")!=NULL, passwd);
733
734
1/2
✓ Branch 0 taken 67 times.
✗ Branch 1 not taken.
67 if(ret)
735 {
736 switch(ret)
737 {
738 case 1:
739 box_out("error.");
740 box_eol();
741 box_end(true);
742 *open_error=qe_notfound;
743 return NULL;
744
745 case 2:
746 box_out("error.");
747 box_eol();
748 box_end(true);
749 *open_error=qe_internal;
750 return NULL;
751 // be sure not to delete tmpfilename now...
752 }
753
754 if(ret==5) //old encryption?
755 {
756 current_method++;
757 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
758 box_out(percent_done);
759 box_load_x();
760 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_211B9, strstr(filename, ".dat#")!=NULL, passwd);
761 }
762
763 if(ret==5) //old encryption?
764 {
765 current_method++;
766 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
767 box_out(percent_done);
768 box_load_x();
769 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_192B185, strstr(filename, ".dat#")!=NULL, passwd);
770 }
771
772 if(ret==5) //old encryption?
773 {
774 current_method++;
775 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
776 box_out(percent_done);
777 box_load_x();
778 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_192B105, strstr(filename, ".dat#")!=NULL, passwd);
779 }
780
781 if(ret==5) //old encryption?
782 {
783 current_method++;
784 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
785 box_out(percent_done);
786 box_load_x();
787 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_192B104, strstr(filename, ".dat#")!=NULL, passwd);
788 }
789
790 if(ret)
791 {
792 oldquest = true;
793 passwd="";
794 }
795 }
796
797 67 box_out("okay.");
798 67 box_eol();
799 67 }
800 else
801 {
802 oldquest = true;
803 }
804
805 67 box_out("Opening...");
806
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 67 times.
67 f = pack_fopen_password(oldquest ? filename : tmpfilename, compressed ? F_READ_PACKED : F_READ, passwd);
807
1/2
✓ Branch 0 taken 67 times.
✗ Branch 1 not taken.
67 if(!f)
808 {
809 if((compressed==1)&&(errno==EDOM))
810 {
811 f = pack_fopen_password(oldquest ? filename : tmpfilename, F_READ, passwd);
812 }
813
814 if(!f)
815 {
816 if(!oldquest)
817 {
818 delete_file(tmpfilename);
819 }
820 box_out("error.");
821 box_eol();
822 box_end(true);
823 *open_error=qe_invalid;
824 return NULL;
825 }
826 }
827
828
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 67 times.
67 if(!oldquest)
829 {
830
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 67 times.
67 if(deletefilename)
831 67 sprintf(deletefilename, "%s", tmpfilename);
832 67 }
833
834 67 box_out("okay.");
835 67 box_eol();
836
837 67 return f;
838 67 }
839
840 9 PACKFILE *open_quest_template(zquestheader *Header, char *deletefilename, bool validate)
841 {
842 char *filename;
843 9 PACKFILE *f=NULL;
844 9 int32_t open_error=0;
845 9 deletefilename[0]=0;
846
847 9 strcpy(qstdat_string,moduledata.datafiles[qst_dat]);
848 9 strcat(qstdat_string,"#NESQST_NEW_QST");
849
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(Header->templatepath[0]==0)
850 {
851 9 filename=(char *)malloc(2048);
852 //strcpy(filename, "qst.dat#NESQST_NEW_QST");
853 9 strcpy(filename, qstdat_string);
854 9 }
855 else
856 {
857 filename=Header->templatepath;
858 }
859
860 9 f=open_quest_file(&open_error, filename, deletefilename, true, true,false);
861
862
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(Header->templatepath[0]==0)
863 {
864 9 free(filename);
865 9 }
866
867
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!f)
868 {
869 return NULL;
870 }
871
872
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(validate)
873 {
874
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!valid_zqt(f))
875 {
876 jwin_alert("Error","Invalid Quest Template",NULL,NULL,"O&K",NULL,'k',0,lfont);
877 pack_fclose(f);
878
879 //setPackfilePassword(NULL);
880 if(deletefilename[0])
881 {
882 delete_file(deletefilename);
883 }
884
885 return NULL;
886 }
887 9 }
888
889 9 return f;
890 9 }
891
892 9 bool init_section(zquestheader *Header, int32_t section_id, miscQdata *Misc, zctune *tunes, bool validate)
893 {
894 9 combosread=false;
895 9 mapsread=false;
896 9 fixffcs=false;
897
898
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 switch(section_id)
899 {
900 case ID_RULES:
901 case ID_STRINGS:
902 case ID_MISC:
903 case ID_TILES:
904 case ID_COMBOS:
905 case ID_CSETS:
906 case ID_MAPS:
907 case ID_DMAPS:
908 case ID_DOORS:
909 case ID_ITEMS:
910 case ID_WEAPONS:
911 case ID_COLORS:
912 case ID_ICONS:
913 case ID_INITDATA:
914 case ID_GUYS:
915 case ID_MIDIS:
916 case ID_CHEATS:
917 case ID_ITEMDROPSETS:
918 case ID_FAVORITES:
919 9 break;
920
921 default:
922 return false;
923 break;
924 }
925
926 int32_t ret;
927 word version, build;
928 9 PACKFILE *f=NULL;
929
930 char deletefilename[1024];
931 9 deletefilename[0]=0;
932
933 //why is this here?
934 /*
935 if(colordata==NULL)
936 return false;
937 */
938
939 //setPackfilePassword(datapwd);
940 9 f=open_quest_template(Header, deletefilename, validate);
941
942
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(!f) //no file, nothing to delete
943 {
944 // setPackfilePassword(NULL);
945 return false;
946 }
947
948 9 ret=get_version_and_build(f, &version, &build);
949
950
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 9 times.
9 if(ret||(version==0))
951 {
952 pack_fclose(f);
953
954 if(deletefilename[0])
955 {
956 delete_file(deletefilename);
957 }
958
959 // setPackfilePassword(NULL);
960 return false;
961 }
962
963
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(!find_section(f, section_id))
964 {
965 9 al_trace("Can't find section!\n");
966 9 pack_fclose(f);
967
968
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(deletefilename[0])
969 {
970 9 delete_file(deletefilename);
971 9 }
972
973 //setPackfilePassword(NULL);
974 9 return false;
975 }
976
977 switch(section_id)
978 {
979 case ID_RULES:
980 //rules
981 ret=readrules(f, Header, true);
982 break;
983
984 case ID_STRINGS:
985 //strings
986 ret=readstrings(f, Header, true);
987 break;
988
989 case ID_MISC:
990 //misc data
991 ret=readmisc(f, Header, Misc, true);
992 break;
993
994 case ID_TILES:
995 //tiles
996 ret=readtiles(f, newtilebuf, Header, version, build, 0, NEWMAXTILES, true, true);
997 break;
998
999 case ID_COMBOS:
1000 //combos
1001 clear_combos();
1002 ret=readcombos(f, Header, version, build, 0, MAXCOMBOS, true);
1003 combosread=true;
1004 break;
1005
1006 case ID_COMBOALIASES:
1007 //combos
1008 ret=readcomboaliases(f, Header, version, build, true);
1009 break;
1010
1011 case ID_CSETS:
1012 //color data
1013 ret=readcolordata(f, Misc, version, build, 0, newerpdTOTAL, true);
1014 break;
1015
1016 case ID_MAPS:
1017 //maps
1018 ret=readmaps(f, Header, true);
1019 mapsread=true;
1020 break;
1021
1022 case ID_DMAPS:
1023 //dmaps
1024 ret=readdmaps(f, Header, version, build, 0, MAXDMAPS, true);
1025 break;
1026
1027 case ID_DOORS:
1028 //door combo sets
1029 ret=readdoorcombosets(f, Header, true);
1030 break;
1031
1032 case ID_ITEMS:
1033 //items
1034 ret=readitems(f, version, build, true);
1035 break;
1036
1037 case ID_WEAPONS:
1038 //weapons
1039 ret=readweapons(f, Header, true);
1040 break;
1041
1042 case ID_COLORS:
1043 //misc. colors
1044 ret=readmisccolors(f, Header, Misc, true);
1045 break;
1046
1047 case ID_ICONS:
1048 //game icons
1049 ret=readgameicons(f, Header, Misc, true);
1050 break;
1051
1052 case ID_INITDATA:
1053 //initialization data
1054 ret=readinitdata(f, Header, true);
1055 break;
1056
1057 case ID_GUYS:
1058 //guys
1059 ret=readguys(f, Header, true);
1060 break;
1061
1062 case ID_MIDIS:
1063 //midis
1064 ret=readtunes(f, Header, tunes, true);
1065 break;
1066
1067 case ID_CHEATS:
1068 //cheat codes
1069 ret=readcheatcodes(f, Header, true);
1070 break;
1071
1072 case ID_ITEMDROPSETS:
1073 //item drop sets
1074 // Why is this one commented out?
1075 //ret=readitemdropsets(f, (int32_t)version, (word)build, true);
1076 break;
1077
1078 case ID_FAVORITES:
1079 // favorite combos and aliases
1080 ret=readfavorites(f, version, build, true);
1081 break;
1082
1083 default:
1084 ret=-1;
1085 break;
1086 }
1087
1088 pack_fclose(f);
1089
1090 if(deletefilename[0])
1091 {
1092 delete_file(deletefilename);
1093 }
1094
1095 //setPackfilePassword(NULL);
1096 if(!ret)
1097 {
1098 return true;
1099 }
1100
1101 return false;
1102 9 }
1103
1104 bool init_tiles(bool validate, zquestheader *Header)
1105 {
1106 return init_section(Header, ID_TILES, NULL, NULL, validate);
1107 }
1108
1109 bool init_combos(bool validate, zquestheader *Header)
1110 {
1111 return init_section(Header, ID_COMBOS, NULL, NULL, validate);
1112 }
1113
1114 bool init_colordata(bool validate, zquestheader *Header, miscQdata *Misc)
1115 {
1116 return init_section(Header, ID_CSETS, Misc, NULL, validate);
1117 }
1118
1119 58 void init_spritelists()
1120 {
1121
2/2
✓ Branch 0 taken 55 times.
✓ Branch 1 taken 3 times.
58 if(FFCore.quest_format[vZelda] < 0x255)
1122 {
1123 55 guys.setMax(255);
1124 55 items.setMax(255);
1125 55 Ewpns.setMax(255);
1126 55 Lwpns.setMax(255);
1127 55 Sitems.setMax(255);
1128 55 chainlinks.setMax(255);
1129 55 decorations.setMax(255);
1130 55 particles.setMax(255);
1131 55 }
1132 else
1133 {
1134 3 guys.setMax(255);
1135 3 items.setMax(255);
1136 3 Ewpns.setMax(255);
1137 3 Lwpns.setMax(255);
1138 3 Sitems.setMax(255);
1139 3 chainlinks.setMax(255);
1140 3 decorations.setMax(255);
1141 3 particles.setMax(255*((255*4)+1)); //255 per sprite that can use particles; guys, items, ewpns, lwpns, +HERO
1142 }
1143 58 }
1144
1145 9 bool reset_items(bool validate, zquestheader *Header)
1146 {
1147 9 bool ret = init_section(Header, ID_ITEMS, NULL, NULL, validate);
1148
1149 //Ignore this, but don't remove it
1150 /*
1151 if (ret)
1152 for(int32_t i=0; i<MAXITEMS; i++)
1153 {
1154 reset_itembuf(&itemsbuf[i], i);
1155 }
1156 */
1157
2/2
✓ Branch 0 taken 2304 times.
✓ Branch 1 taken 9 times.
2313 for(int32_t i=0; i<MAXITEMS; i++) reset_itemname(i);
1158
1159 9 return ret;
1160 }
1161
1162 bool reset_guys()
1163 {
1164 // The .dat file's guys definitions are always synchronised with defdata.cpp's - even the tile settings.
1165 init_guys(V_GUYS);
1166 return true;
1167 }
1168
1169 bool reset_wpns(bool validate, zquestheader *Header)
1170 {
1171 bool ret = init_section(Header, ID_WEAPONS, NULL, NULL, validate);
1172
1173 for(int32_t i=0; i<WPNCNT; i++)
1174 reset_weaponname(i);
1175
1176 return ret;
1177 }
1178
1179 bool reset_mapstyles(bool validate, miscQdata *Misc)
1180 {
1181 Misc->colors.blueframe_tile = 20044;
1182 Misc->colors.blueframe_cset = 0;
1183 Misc->colors.triforce_tile = 23461;
1184 Misc->colors.triforce_cset = 1;
1185 Misc->colors.triframe_tile = 18752;
1186 Misc->colors.triframe_cset = 1;
1187 Misc->colors.overworld_map_tile = 16990;
1188 Misc->colors.overworld_map_cset = 2;
1189 Misc->colors.HCpieces_tile = 21160;
1190 Misc->colors.HCpieces_cset = 8;
1191 Misc->colors.dungeon_map_tile = 19651;
1192 Misc->colors.dungeon_map_cset = 8;
1193 return true;
1194 }
1195
1196 bool reset_doorcombosets(bool validate, zquestheader *Header)
1197 {
1198 return init_section(Header, ID_DOORS, NULL, NULL, validate);
1199 }
1200
1201 9 int32_t get_qst_buffers()
1202 {
1203 9 memrequested+=(sizeof(mapscr)*MAPSCRS);
1204 9 Z_message("Allocating map buffer (%s)... ", byte_conversion2(sizeof(mapscr)*MAPSCRS,memrequested,-1, -1));
1205 9 TheMaps.resize(MAPSCRS);
1206
1207
2/2
✓ Branch 0 taken 1224 times.
✓ Branch 1 taken 9 times.
1233 for(int32_t i(0); i<MAPSCRS; i++)
1208 1224 TheMaps[i].zero_memory();
1209
1210 //memset(TheMaps, 0, sizeof(mapscr)*MAPSCRS); //shouldn't need this anymore
1211 9 Z_message("OK\n"); // Allocating map buffer...
1212
1213 9 memrequested+=(sizeof(zcmap)*MAXMAPS2);
1214 9 Z_message("Allocating combo buffer (%s)... ", byte_conversion2(sizeof(zcmap)*MAXMAPS2,memrequested,-1,-1));
1215
1216
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if((ZCMaps=(zcmap*)malloc(sizeof(zcmap)*MAXMAPS2))==NULL)
1217 return 0;
1218
1219 9 Z_message("OK\n");
1220
1221 // Allocating space for all 65535 strings uses up 10.62MB...
1222 // The vast majority of finished quests (and I presume this will be consistent for all time) use < 1000 strings in total.
1223 // (Shoelace's "Hero of Dreams" uses 1415.)
1224 // So let's be a bit generous and allow 4096 initially.
1225 // In the rare event that a quest overshoots this mark, we'll reallocate to the full 65535 later.
1226 // I tested it and it worked without flaw on 6/6/11. - L.
1227 // 2022: bumped from 4096 to 8192 to avoid a bug where the Strings menu shows (None) strings when the list passes
1228 // this threshold. Possibly some bug related to `msglistcache` to being reset?
1229 // See https://discord.com/channels/876899628556091432/992984989073416242
1230 9 msg_strings_size = 8192;
1231 9 memrequested+=(sizeof(MsgStr)*msg_strings_size);
1232 9 Z_message("Allocating string buffer (%s)... ", byte_conversion2(sizeof(MsgStr)*msg_strings_size,memrequested,-1,-1));
1233
1234
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 MsgStrings = new MsgStr[msg_strings_size];
1235
1236 //memset(MsgStrings, 0, sizeof(MsgStr)*msg_strings_size);
1237
2/2
✓ Branch 0 taken 73728 times.
✓ Branch 1 taken 9 times.
73737 for(auto q = 0; q < msg_strings_size; ++q)
1238 {
1239 73728 MsgStrings[q].clear();
1240 73728 }
1241 9 Z_message("OK\n"); // Allocating string buffer...
1242
1243 9 memrequested+=(sizeof(DoorComboSet)*MAXDOORCOMBOSETS);
1244 9 Z_message("Allocating door combo buffer (%s)... ", byte_conversion2(sizeof(DoorComboSet)*MAXDOORCOMBOSETS,memrequested,-1,-1));
1245
1246
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if((DoorComboSets=(DoorComboSet*)malloc(sizeof(DoorComboSet)*MAXDOORCOMBOSETS))==NULL)
1247 return 0;
1248
1249 9 Z_message("OK\n"); // Allocating door combo buffer...
1250
1251 9 memrequested+=(sizeof(dmap)*MAXDMAPS);
1252 9 Z_message("Allocating dmap buffer (%s)... ", byte_conversion2(sizeof(dmap)*MAXDMAPS,memrequested,-1,-1));
1253
1254
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if((DMaps=(dmap*)malloc(sizeof(dmap)*MAXDMAPS))==NULL)
1255 return 0;
1256
1257 9 memset(DMaps, 0, sizeof(dmap)*MAXDMAPS);
1258 9 Z_message("OK\n"); // Allocating dmap buffer...
1259
1260 9 memrequested+=(sizeof(newcombo)*MAXCOMBOS);
1261 9 Z_message("Allocating combo buffer (%s)... ", byte_conversion2(sizeof(newcombo)*MAXCOMBOS,memrequested,-1,-1));
1262
1263
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if((combobuf=(newcombo*)malloc(sizeof(newcombo)*MAXCOMBOS))==NULL)
1264 return 0;
1265
1266 9 memset(combobuf, 0, sizeof(newcombo)*MAXCOMBOS);
1267 9 Z_message("OK\n"); // Allocating combo buffer...
1268
1269 9 memrequested+=(psTOTAL255);
1270 9 Z_message("Allocating color data buffer (%s)... ", byte_conversion2(psTOTAL255,memrequested,-1,-1));
1271
1272
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if((colordata=(byte*)malloc(psTOTAL255))==NULL)
1273 return 0;
1274
1275 9 Z_message("OK\n"); // Allocating color data buffer...
1276
1277 9 memrequested+=(NEWMAXTILES*(sizeof(tiledata)+tilesize(tf4Bit)));
1278 9 Z_message("Allocating tile buffer (%s)... ", byte_conversion2(NEWMAXTILES*(sizeof(tiledata)+tilesize(tf4Bit)),memrequested,-1,-1));
1279
1280 9 free_newtilebuf();
1281
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if((newtilebuf=(tiledata*)malloc(NEWMAXTILES*sizeof(tiledata)))==NULL)
1282 return 0;
1283
1284 9 memset(newtilebuf, 0, NEWMAXTILES*sizeof(tiledata));
1285 //Z_message("Performed memset on tiles\n");
1286 9 clear_tiles(newtilebuf);
1287 //Z_message("Performed clear_tiles()\n");
1288 9 Z_message("OK\n"); // Allocating tile buffer...
1289
1290
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(is_zquest())
1291 {
1292 memrequested+=(NEWMAXTILES*(sizeof(tiledata)+tilesize(tf4Bit)));
1293 Z_message("Allocating tile grab buffer (%s)... ", byte_conversion2(NEWMAXTILES*sizeof(tiledata),memrequested,-1,-1));
1294
1295 if((grabtilebuf=(tiledata*)malloc(NEWMAXTILES*sizeof(tiledata)))==NULL)
1296 return 0;
1297
1298 memset(grabtilebuf, 0, NEWMAXTILES*sizeof(tiledata));
1299 clear_tiles(grabtilebuf);
1300 Z_message("OK\n"); // Allocating tile grab buffer...
1301 }
1302
1303 9 memrequested+=(100000);
1304 9 Z_message("Allocating trash buffer (%s)... ", byte_conversion2(100000,memrequested,-1,-1));
1305
1306
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if((trashbuf=(byte*)malloc(100000))==NULL)
1307 return 0;
1308
1309 9 Z_message("OK\n"); // Allocating trash buffer...
1310
1311 // Big, ugly band-aid here. Perhaps the most common cause of random crashes
1312 // has been inadvertently accessing itemsbuf[-1]. All such crashes should be
1313 // fixed by ensuring there's actually itemdata there.
1314 // If you change this, be sure to update del_qst_buffers, too.
1315
1316 9 memrequested+=(sizeof(itemdata)*(MAXITEMS+1));
1317 9 Z_message("Allocating item buffer (%s)... ", byte_conversion2(sizeof(itemdata)*(MAXITEMS+1),memrequested,-1,-1));
1318
1319
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if((itemsbuf=(itemdata*)malloc(sizeof(itemdata)*(MAXITEMS+1)))==NULL)
1320 return 0;
1321
1322 9 memset(itemsbuf,0,sizeof(itemdata)*(MAXITEMS+1));
1323 9 itemsbuf++;
1324 9 Z_message("OK\n"); // Allocating item buffer...
1325
1326 9 memrequested+=(sizeof(wpndata)*MAXWPNS);
1327 9 Z_message("Allocating weapon buffer (%s)... ", byte_conversion2(sizeof(wpndata)*MAXWPNS,memrequested,-1,-1));
1328
1329
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if((wpnsbuf=(wpndata*)malloc(sizeof(wpndata)*MAXWPNS))==NULL)
1330 return 0;
1331
1332 9 memset(wpnsbuf,0,sizeof(wpndata)*MAXWPNS);
1333 9 Z_message("OK\n"); // Allocating weapon buffer...
1334
1335 9 memrequested+=(sizeof(guydata)*MAXGUYS);
1336 9 Z_message("Allocating guy buffer (%s)... ", byte_conversion2(sizeof(guydata)*MAXGUYS,memrequested,-1,-1));
1337
1338
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if((guysbuf=(guydata*)malloc(sizeof(guydata)*MAXGUYS))==NULL)
1339 return 0;
1340
1341 9 memset(guysbuf,0,sizeof(guydata)*MAXGUYS);
1342 9 Z_message("OK\n"); // Allocating guy buffer...
1343
1344 9 memrequested+=(sizeof(comboclass)*cMAX);
1345 9 Z_message("Allocating combo class buffer (%s)... ", byte_conversion2(sizeof(comboclass)*cMAX,memrequested,-1,-1));
1346
1347
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if((combo_class_buf=(comboclass*)malloc(sizeof(comboclass)*cMAX))==NULL)
1348 return 0;
1349
1350 9 Z_message("OK\n"); // Allocating combo class buffer...
1351
1352 9 return 1;
1353 9 }
1354
1355
1356 9 void free_newtilebuf()
1357 {
1358
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(newtilebuf)
1359 {
1360 for(int32_t i=0; i<NEWMAXTILES; i++)
1361 if(newtilebuf[i].data)
1362 free(newtilebuf[i].data);
1363
1364 free(newtilebuf);
1365 newtilebuf = 0;
1366 }
1367 9 }
1368
1369 void free_grabtilebuf()
1370 {
1371 if(is_zquest())
1372 {
1373 if(grabtilebuf)
1374 {
1375 for(int32_t i=0; i<NEWMAXTILES; i++)
1376 if(grabtilebuf[i].data) free(grabtilebuf[i].data);
1377
1378 free(grabtilebuf);
1379 grabtilebuf = 0;
1380 }
1381 }
1382 }
1383
1384 void del_qst_buffers()
1385 {
1386 al_trace("Cleaning maps. \n");
1387
1388 if(ZCMaps) free(ZCMaps);
1389
1390 if(MsgStrings) delete[] MsgStrings;
1391
1392 if(DoorComboSets) free(DoorComboSets);
1393
1394 if(DMaps) free(DMaps);
1395
1396 if(combobuf) free(combobuf);
1397
1398 if(colordata) free(colordata);
1399
1400 al_trace("Cleaning tile buffers. \n");
1401 free_newtilebuf();
1402 free_grabtilebuf();
1403
1404 al_trace("Cleaning misc. \n");
1405
1406 if(trashbuf) free(trashbuf);
1407
1408 // See get_qst_buffers
1409 if(itemsbuf)
1410 {
1411 itemsbuf--;
1412 free(itemsbuf);
1413 }
1414
1415 if(wpnsbuf) free(wpnsbuf);
1416
1417 if(guysbuf) free(guysbuf);
1418
1419 if(combo_class_buf) free(combo_class_buf);
1420 }
1421
1422 bool init_palnames()
1423 {
1424 // if(palnames==NULL)
1425 // return false;
1426
1427 for(int32_t x=0; x<MAXLEVELS; x++)
1428 {
1429 switch(x)
1430 {
1431 case 0:
1432 sprintf(palnames[x],"Overworld");
1433 break;
1434
1435 case 10:
1436 sprintf(palnames[x],"Caves");
1437 break;
1438
1439 case 11:
1440 sprintf(palnames[x],"Passageways");
1441 break;
1442
1443 default:
1444 sprintf(palnames[x],"%c",0);
1445 break;
1446 }
1447 }
1448
1449 return true;
1450 }
1451
1452 14242 static void *read_block(PACKFILE *f, int32_t size, int32_t alloc_size, bool keepdata)
1453 {
1454 void *p;
1455
1456
1/2
✓ Branch 0 taken 14242 times.
✗ Branch 1 not taken.
14242 p = _AL_MALLOC(MAX(size, alloc_size));
1457
1458
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14242 times.
14242 if(!p)
1459 {
1460 return NULL;
1461 }
1462
1463
1/2
✓ Branch 0 taken 14242 times.
✗ Branch 1 not taken.
14242 if(!pfread(p,size,f,keepdata))
1464 {
1465 _AL_FREE(p);
1466 return NULL;
1467 }
1468
1469
1/2
✓ Branch 0 taken 14242 times.
✗ Branch 1 not taken.
14242 if(pack_ferror(f))
1470 {
1471 _AL_FREE(p);
1472 return NULL;
1473 }
1474
1475 14242 return p;
1476 14242 }
1477
1478 /* read_midi:
1479 * Reads MIDI data from a datafile (this is not the same thing as the
1480 * standard midi file format).
1481 */
1482
1483 1181 static MIDI *read_midi(PACKFILE *f, bool)
1484 {
1485 MIDI *m;
1486 int32_t c;
1487 1181 int16_t divisions=0;
1488 1181 int32_t len=0;
1489
1490 1181 m = (MIDI*)_AL_MALLOC(sizeof(MIDI));
1491
1492
1/2
✓ Branch 0 taken 1181 times.
✗ Branch 1 not taken.
1181 if(!m)
1493 {
1494 return NULL;
1495 }
1496
1497
2/2
✓ Branch 0 taken 37792 times.
✓ Branch 1 taken 1181 times.
38973 for(c=0; c<MIDI_TRACKS; c++)
1498 {
1499 37792 m->track[c].len = 0;
1500 37792 m->track[c].data = NULL;
1501 37792 }
1502
1503 1181 p_mgetw(&divisions,f,true);
1504 1181 m->divisions=divisions;
1505
1506
2/2
✓ Branch 0 taken 37792 times.
✓ Branch 1 taken 1181 times.
38973 for(c=0; c<MIDI_TRACKS; c++)
1507 {
1508 37792 p_mgetl(&len,f,true);
1509 37792 m->track[c].len=len;
1510
1511
2/2
✓ Branch 0 taken 23550 times.
✓ Branch 1 taken 14242 times.
37792 if(m->track[c].len > 0)
1512 {
1513 14242 m->track[c].data = (byte*)read_block(f, m->track[c].len, 0, true);
1514
1515
1/2
✓ Branch 0 taken 14242 times.
✗ Branch 1 not taken.
14242 if(!m->track[c].data)
1516 {
1517 destroy_midi(m);
1518 return NULL;
1519 }
1520 14242 }
1521 37792 }
1522
1523 LOCK_DATA(m, sizeof(MIDI));
1524
1525
2/2
✓ Branch 0 taken 37792 times.
✓ Branch 1 taken 1181 times.
38973 for(c=0; c<MIDI_TRACKS; c++)
1526 {
1527
2/2
✓ Branch 0 taken 14242 times.
✓ Branch 1 taken 23550 times.
37792 if(m->track[c].data)
1528 {
1529 LOCK_DATA(m->track[c].data, m->track[c].len);
1530 14242 }
1531 37792 }
1532
1533 1181 return m;
1534 1181 }
1535
1536 void clear_combo(int32_t i)
1537 {
1538 combobuf[i].clear();
1539 }
1540
1541 void clear_combos()
1542 {
1543 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
1544 clear_combo(tmpcounter);
1545 }
1546
1547 void pack_combos()
1548 {
1549 int32_t di = 0;
1550
1551 for(int32_t si=0; si<1024; si+=2)
1552 combobuf[di++] = combobuf[si];
1553
1554 for(; di<1024; di++)
1555 clear_combo(di);
1556 }
1557
1558 58 void reset_tunes(zctune *tune)
1559 {
1560
2/2
✓ Branch 0 taken 14616 times.
✓ Branch 1 taken 58 times.
14674 for(int32_t i=0; i<MAXCUSTOMTUNES; i++)
1561 {
1562 14616 tune[i].reset();
1563 14616 }
1564 58 }
1565
1566
1567 /*void reset_midi(zcmidi_ *m)
1568 {
1569 m->title[0]=0;
1570 m->loop=1;
1571 m->volume=144;
1572 m->start=0;
1573 m->loop_start=-1;
1574 m->loop_end=-1;
1575 if(m->midi)
1576 {
1577 destroy_midi(m->midi);
1578 }
1579 m->midi=NULL;
1580 }
1581
1582
1583 void reset_midis(zcmidi_ *m)
1584 {
1585 for(int32_t i=0; i<MAXCUSTOMMIDIS; i++)
1586 {
1587 reset_midi(m+i);
1588 }
1589 }
1590 */
1591
1592 void reset_scr(int32_t scr)
1593 {
1594 /*
1595 byte *di=((byte*)TheMaps)+(scr*sizeof(mapscr));
1596 for(unsigned i=0; i<sizeof(mapscr); i++)
1597 *(di++) = 0;
1598 TheMaps[scr].valid=mVERSION;
1599 */
1600
1601 TheMaps[scr].zero_memory();
1602 //byte *di=((byte*)TheMaps)+(scr*sizeof(mapscr));
1603
1604 for(int32_t i=0; i<6; i++)
1605 {
1606 //these will be uncommented later
1607 //TheMaps[scr].layerxsize[i]=16;
1608 //TheMaps[scr].layerysize[i]=11;
1609 TheMaps[scr].layeropacity[i]=255;
1610 }
1611
1612 TheMaps[scr].valid=mVERSION;
1613
1614 }
1615
1616 /* For reference:
1617
1618 enum { qe_OK, qe_notfound, qe_invalid, qe_version, qe_obsolete,
1619 qe_missing, qe_internal, qe_pwd, qe_match, qe_minver };
1620 */
1621
1622 int32_t operator ==(DoorComboSet a, DoorComboSet b)
1623 {
1624 for(int32_t i=0; i<9; i++)
1625 {
1626 for(int32_t j=0; j<6; j++)
1627 {
1628 if(j<4)
1629 {
1630 if(a.doorcombo_u[i][j]!=b.doorcombo_u[i][j])
1631 {
1632 return false;
1633 }
1634
1635 if(a.doorcset_u[i][j]!=b.doorcset_u[i][j])
1636 {
1637 return false;
1638 }
1639
1640 if(a.doorcombo_d[i][j]!=b.doorcombo_d[i][j])
1641 {
1642 return false;
1643 }
1644
1645 if(a.doorcset_d[i][j]!=b.doorcset_d[i][j])
1646 {
1647 return false;
1648 }
1649 }
1650
1651 if(a.doorcombo_l[i][j]!=b.doorcombo_l[i][j])
1652 {
1653 return false;
1654 }
1655
1656 if(a.doorcset_l[i][j]!=b.doorcset_l[i][j])
1657 {
1658 return false;
1659 }
1660
1661 if(a.doorcombo_r[i][j]!=b.doorcombo_r[i][j])
1662 {
1663 return false;
1664 }
1665
1666 if(a.doorcset_r[i][j]!=b.doorcset_r[i][j])
1667 {
1668 return false;
1669 }
1670 }
1671
1672 if(i<2)
1673 {
1674 if(a.flags[i]!=b.flags[i])
1675 {
1676 return false;
1677 }
1678
1679 if(a.bombdoorcombo_u[i]!=b.bombdoorcombo_u[i])
1680 {
1681 return false;
1682 }
1683
1684 if(a.bombdoorcset_u[i]!=b.bombdoorcset_u[i])
1685 {
1686 return false;
1687 }
1688
1689 if(a.bombdoorcombo_d[i]!=b.bombdoorcombo_d[i])
1690 {
1691 return false;
1692 }
1693
1694 if(a.bombdoorcset_d[i]!=b.bombdoorcset_d[i])
1695 {
1696 return false;
1697 }
1698 }
1699
1700 if(i<3)
1701 {
1702 if(a.bombdoorcombo_l[i]!=b.bombdoorcombo_l[i])
1703 {
1704 return false;
1705 }
1706
1707 if(a.bombdoorcset_l[i]!=b.bombdoorcset_l[i])
1708 {
1709 return false;
1710 }
1711
1712 if(a.bombdoorcombo_r[i]!=b.bombdoorcombo_r[i])
1713 {
1714 return false;
1715 }
1716
1717 if(a.bombdoorcset_r[i]!=b.bombdoorcset_r[i])
1718 {
1719 return false;
1720 }
1721 }
1722
1723 if(a.walkthroughcombo[i]!=b.walkthroughcombo[i])
1724 {
1725 return false;
1726 }
1727
1728 if(a.walkthroughcset[i]!=b.walkthroughcset[i])
1729 {
1730 return false;
1731 }
1732 }
1733
1734 return true;
1735 }
1736
1737 int32_t doortranslations_u[9][4]=
1738 {
1739 {37,38,53,54},
1740 {37,38,39,40},
1741 {37,38,55,56},
1742 {37,38,39,40},
1743 {37,38,53,54},
1744 {37,38,53,54},
1745 {37,38,53,54},
1746 {7,8,23,24},
1747 {7,8,41,42}
1748 };
1749
1750 int32_t doortranslations_d[9][4]=
1751 {
1752 {117,118,133,134},
1753 {135,136,133,134},
1754 {119,120,133,134},
1755 {135,136,133,134},
1756 {117,118,133,134},
1757 {117,118,133,134},
1758 {117,118,133,134},
1759 {151,152,167,168},
1760 {137,138,167,168},
1761 };
1762
1763 //enum {dt_pass=0, dt_lock, dt_shut, dt_boss, dt_olck, dt_osht, dt_obos, dt_wall, dt_bomb, dt_walk, dt_max};
1764 int32_t doortranslations_l[9][6]=
1765 {
1766 {66,67,82,83,98,99},
1767 {66,68,82,84,98,100},
1768 {66,69,82,85,98,101},
1769 {66,68,82,84,98,100},
1770 {66,67,82,83,98,99},
1771 {66,67,82,83,98,99},
1772 {66,67,82,83,98,99},
1773 {64,65,80,81,96,97},
1774 {64,65,80,114,96,97},
1775 };
1776
1777 int32_t doortranslations_r[9][6]=
1778 {
1779
1780 {76,77,92,93,108,109},
1781 {75,77,91,93,107,109},
1782 {74,77,90,93,106,109},
1783 {75,77,91,93,107,109},
1784 {76,77,92,93,108,109},
1785 {76,77,92,93,108,109},
1786 {76,77,92,93,108,109},
1787 {78,79,94,95,110,111},
1788 {78,79,125,95,110,111},
1789 };
1790
1791 int32_t tdcmbdat(int32_t map, int32_t scr, int32_t pos)
1792 {
1793 return (TheMaps[map*MAPSCRS+TEMPLATE].data[pos]&0xFF)+((TheMaps[map*MAPSCRS+scr].old_cpage)<<8);
1794 }
1795
1796 int32_t tdcmbcset(int32_t map, int32_t scr, int32_t pos)
1797 {
1798 //these are here to bypass compiler warnings about unused arguments
1799 map=map;
1800 scr=scr;
1801 pos=pos;
1802
1803 //what does this function do?
1804 // return TheMaps[map*MAPSCRS+TEMPLATE].cset[pos];
1805 return 2;
1806 }
1807
1808 int32_t MakeDoors(int32_t map, int32_t scr)
1809 {
1810 if(!(TheMaps[map*MAPSCRS+scr].valid&mVALID))
1811 {
1812 return 0;
1813 }
1814
1815 DoorComboSet tempdcs;
1816 memset(&tempdcs, 0, sizeof(DoorComboSet));
1817
1818 //up
1819 for(int32_t i=0; i<9; i++)
1820 {
1821 for(int32_t j=0; j<4; j++)
1822 {
1823 tempdcs.doorcombo_u[i][j]=tdcmbdat(map,scr,doortranslations_u[i][j]);
1824 tempdcs.doorcset_u[i][j]=tdcmbcset(map,scr,doortranslations_u[i][j]);
1825 }
1826 }
1827
1828 tempdcs.bombdoorcombo_u[0]=tdcmbdat(map,scr,57);
1829 tempdcs.bombdoorcset_u[0]=tdcmbcset(map,scr,57);
1830 tempdcs.bombdoorcombo_u[1]=tdcmbdat(map,scr,58);
1831 tempdcs.bombdoorcset_u[1]=tdcmbcset(map,scr,58);
1832 tempdcs.walkthroughcombo[0]=tdcmbdat(map,scr,34);
1833 tempdcs.walkthroughcset[0]=tdcmbdat(map,scr,34);
1834
1835 //down
1836 for(int32_t i=0; i<9; i++)
1837 {
1838 for(int32_t j=0; j<4; j++)
1839 {
1840 tempdcs.doorcombo_d[i][j]=tdcmbdat(map,scr,doortranslations_d[i][j]);
1841 tempdcs.doorcset_d[i][j]=tdcmbcset(map,scr,doortranslations_d[i][j]);
1842 }
1843 }
1844
1845 tempdcs.bombdoorcombo_d[0]=tdcmbdat(map,scr,121);
1846
1847 tempdcs.bombdoorcset_d[0]=tdcmbcset(map,scr,121);
1848 tempdcs.bombdoorcombo_d[1]=tdcmbdat(map,scr,122);
1849 tempdcs.bombdoorcset_d[1]=tdcmbcset(map,scr,122);
1850 tempdcs.walkthroughcombo[1]=tdcmbdat(map,scr,34);
1851 tempdcs.walkthroughcset[1]=tdcmbdat(map,scr,34);
1852
1853 //left
1854 // TheMaps[i*MAPSCRS+j].warpdmap=TheOldMap.warpdmap;
1855 for(int32_t i=0; i<9; i++)
1856 {
1857 for(int32_t j=0; j<6; j++)
1858 {
1859 tempdcs.doorcombo_l[i][j]=tdcmbdat(map,scr,doortranslations_l[i][j]);
1860 tempdcs.doorcset_l[i][j]=tdcmbcset(map,scr,doortranslations_l[i][j]);
1861 }
1862 }
1863
1864 for(int32_t j=0; j>6; j++)
1865 {
1866 if((j!=2)&&(j!=3))
1867 {
1868 tempdcs.doorcombo_l[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].data[doortranslations_l[dt_bomb][j]];
1869 tempdcs.doorcset_l[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].cset[doortranslations_l[dt_bomb][j]];
1870 }
1871 }
1872
1873 tempdcs.bombdoorcombo_l[0]=0;
1874 tempdcs.bombdoorcset_l[0]=tdcmbcset(map,scr,115);
1875 tempdcs.bombdoorcombo_l[1]=tdcmbdat(map,scr,115);
1876 tempdcs.bombdoorcset_l[1]=tdcmbcset(map,scr,115);
1877 tempdcs.bombdoorcombo_l[2]=0;
1878 tempdcs.bombdoorcset_l[2]=tdcmbcset(map,scr,115);
1879 tempdcs.walkthroughcombo[2]=tdcmbdat(map,scr,34);
1880 tempdcs.walkthroughcset[2]=tdcmbdat(map,scr,34);
1881
1882 //right
1883 for(int32_t i=0; i<9; i++)
1884 {
1885 for(int32_t j=0; j<6; j++)
1886 {
1887 tempdcs.doorcombo_r[i][j]=tdcmbdat(map,scr,doortranslations_r[i][j]);
1888 tempdcs.doorcset_r[i][j]=tdcmbcset(map,scr,doortranslations_r[i][j]);
1889 }
1890 }
1891
1892 for(int32_t j=0; j>6; j++)
1893 {
1894 if((j!=2)&&(j!=3))
1895 {
1896 tempdcs.doorcombo_r[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].data[doortranslations_r[dt_bomb][j]];
1897 tempdcs.doorcset_r[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].cset[doortranslations_r[dt_bomb][j]];
1898 }
1899 }
1900
1901 tempdcs.bombdoorcombo_r[0]=0;
1902 tempdcs.bombdoorcset_r[0]=tdcmbcset(map,scr,124);
1903 tempdcs.bombdoorcombo_r[1]=tdcmbdat(map,scr,124);
1904 tempdcs.bombdoorcset_r[1]=tdcmbcset(map,scr,124);
1905 tempdcs.bombdoorcombo_r[2]=0;
1906 tempdcs.bombdoorcset_r[2]=tdcmbcset(map,scr,124);
1907 tempdcs.walkthroughcombo[3]=tdcmbdat(map,scr,34);
1908 tempdcs.walkthroughcset[3]=tdcmbdat(map,scr,34);
1909
1910 int32_t k;
1911
1912 for(k=0; k<door_combo_set_count; k++)
1913 {
1914 if(DoorComboSets[k]==tempdcs)
1915 {
1916 break;
1917 }
1918 }
1919
1920 if(k==door_combo_set_count)
1921 {
1922 DoorComboSets[k]=tempdcs;
1923 sprintf(DoorComboSets[k].name, "Door Combo Set %d", k);
1924 ++door_combo_set_count;
1925 }
1926
1927 return k;
1928 /*
1929 doorcombo_u[9][4];
1930 doorcset_u[9][4];
1931 doorcombo_d[9][4];
1932 doorcset_d[9][4];
1933 doorcombo_l[9][6];
1934 doorcset_l[9][6];
1935 doorcombo_r[9][6];
1936 doorcset_r[9][6];
1937 bombdoorcombo_u[2];
1938 bombdoorcset_u[2];
1939 bombdoorcombo_d[2];
1940 bombdoorcset_d[2];
1941 bombdoorcombo_l[3];
1942 bombdoorcset_l[3];
1943 bombdoorcombo_r[3];
1944 bombdoorcset_r[3];
1945 walkthroughcombo[4];
1946 walkthroughcset[4];
1947 */
1948 }
1949
1950 INLINE int32_t tcmbdat2(int32_t map, int32_t scr, int32_t pos)
1951 {
1952 return (TheMaps[map*MAPSCRS+TEMPLATE2].data[pos]&0xFF)+((TheMaps[map*MAPSCRS+scr].old_cpage)<<8);
1953 }
1954
1955 INLINE int32_t tcmbcset2(int32_t map, int32_t pos)
1956 {
1957
1958 return TheMaps[map*MAPSCRS+TEMPLATE2].cset[pos];
1959 }
1960
1961 INLINE int32_t tcmbflag2(int32_t map, int32_t pos)
1962 {
1963 return TheMaps[map*MAPSCRS+TEMPLATE2].sflag[pos];
1964 }
1965
1966
1967 void get_questpwd(char *encrypted_pwd, int16_t pwdkey, char *pwd)
1968 {
1969 char temp_pwd[30];
1970 memset(temp_pwd,0,30);
1971
1972 if(pwdkey!=0)
1973 {
1974 memcpy(temp_pwd,encrypted_pwd,30);
1975 temp_pwd[29]=0;
1976
1977 for(int32_t i=0; i<30; i++)
1978 {
1979 temp_pwd[i] -= pwdkey;
1980 int32_t t=pwdkey>>15;
1981 pwdkey = (pwdkey<<1)+t;
1982 }
1983 }
1984
1985 memcpy(pwd,temp_pwd,30);
1986 }
1987
1988
1989
1990 bool check_questpwd(zquestheader *Header, char *pwd)
1991 {
1992 #if DEVLEVEL > 3
1993 return true;
1994 #endif
1995
1996 if ( (!strcmp(pwd, (char*)clavio)) ) return true;
1997 cvs_MD5Context ctx;
1998 uint8_t md5sum[16];
1999
2000 cvs_MD5Init(&ctx);
2001 cvs_MD5Update(&ctx, (const uint8_t*)pwd, (unsigned)strlen(pwd));
2002 cvs_MD5Final(md5sum, &ctx);
2003
2004 return (memcmp(Header->pwd_hash,md5sum,16)==0);
2005
2006 }
2007
2008 57 void print_quest_metadata(zquestheader const& tempheader, char const* path, byte qst_num)
2009 {
2010 57 zprint2("\n");
2011 57 zprint2("[ZQUEST CREATOR METADATA]\n");
2012
1/2
✓ Branch 0 taken 57 times.
✗ Branch 1 not taken.
57 if(qst_num < moduledata.max_quest_files)
2013 zprint2("Loading module quest %d\n", qst_num+1);
2014
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 57 times.
57 if(path) zprint2("Loading '%s'\n", path);
2015
1/2
✓ Branch 0 taken 57 times.
✗ Branch 1 not taken.
57 if ( tempheader.new_version_id_main > 0 )
2016 {
2017
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 57 times.
57 if(tempheader.new_version_id_fourth > 0)
2018 zprint2("Last saved in ZQuest Version %d.%d.%d.%d ",
2019 tempheader.new_version_id_main,tempheader.new_version_id_second,
2020 tempheader.new_version_id_third,tempheader.new_version_id_fourth);
2021 57 else zprint2("Last saved in ZQuest Version: %d.%d.%d ",
2022 57 tempheader.new_version_id_main,tempheader.new_version_id_second,
2023 57 tempheader.new_version_id_third);
2024 57 }
2025 else
2026 {
2027 switch ( tempheader.zelda_version )
2028 {
2029 case 0x255:
2030 {
2031 zprint2("Last saved in ZQuest Version: 2.55.0, %s: %d", tempheader.getAlphaStr(), tempheader.getAlphaVer());
2032 break;
2033 }
2034 case 0x254:
2035 {
2036 zprint2("Last saved in ZQuest Version: 2.54.0, Alpha Build ID: %d", tempheader.build);
2037 break;
2038 }
2039 case 0x250:
2040 {
2041 switch(tempheader.build)
2042 {
2043 case 19:
2044 zprint2("Last saved in ZQuest Version: 2.50.0, Gamma 1"); break;
2045 case 20:
2046 zprint2("Last saved in ZQuest Version: 2.50.0, Gamma 2"); break;
2047 case 21:
2048 zprint2("Last saved in ZQuest Version: 2.50.0, Gamma 3"); break;
2049 case 22:
2050 zprint2("Last saved in ZQuest Version: 2.50.0, Gamma 4"); break;
2051 case 23:
2052 zprint2("Last saved in ZQuest Version: 2.50.0, Gamma 5"); break;
2053 case 24:
2054 zprint2("Last saved in ZQuest Version: 2.50.0, Release"); break;
2055 case 25:
2056 zprint2("Last saved in ZQuest Version: 2.50.1, Gamma 1"); break;
2057 case 26:
2058 zprint2("Last saved in ZQuest Version: 2.50.1, Gamma 2"); break;
2059 case 27:
2060 zprint2("Last saved in ZQuest Version: 2.50.1, Gamma 3"); break;
2061 case 28:
2062 zprint2("Last saved in ZQuest Version: 2.50.1, Release"); break;
2063 case 29:
2064 zprint2("Last saved in ZQuest Version: 2.50.2, Release"); break;
2065 case 30:
2066 zprint2("Last saved in ZQuest Version: 2.50.3, Gamma 1"); break;
2067 case 31:
2068 zprint2("Last saved in ZQuest Version: 2.53.0, Prior to Gamma 3"); break;
2069 case 32:
2070 zprint2("Last saved in ZQuest Version: 2.53.0"); break;
2071 case 33:
2072 zprint2("Last saved in ZQuest Version: 2.53.1"); break;
2073 default:
2074 zprint2("Last saved in ZQuest Version: %x, Build %d", tempheader.zelda_version,tempheader.build); break;
2075
2076 }
2077 break;
2078 }
2079
2080 case 0x211:
2081 {
2082 zprint2("Last saved in ZQuest Version: 2.11, Beta %d", tempheader.build); break;
2083 }
2084 case 0x210:
2085 {
2086 zprint2("Last saved in ZQuest Version: 2.10.x");
2087 if ( tempheader.build ) zprint2("Beta/Build %d\n", tempheader.build);
2088 break;
2089 }
2090 /* These versions cannot be handled here; they will be incorrect at this time. -Z
2091 case 0x193:
2092 {
2093 zprint2("Last saved in ZQuest Version: 1.93, Beta %d\n", tempheader.build); break;
2094 }
2095 case 0x192:
2096 {
2097 zprint2("Last saved in ZQuest Version: 1.92, Beta %d\n", tempheader.build); break;
2098 }
2099 case 0x190:
2100 {
2101 zprint2("Last saved in ZQuest Version: 1.90, Beta/Build %d\n", tempheader.build); break;
2102 }
2103 case 0x184:
2104 {
2105 zprint2("Last saved in ZQuest Version: 1.84, Beta/Build %d\n", tempheader.build); break;
2106 }
2107 case 0x183:
2108 {
2109 zprint2("Last saved in ZQuest Version: 1.83, Beta/Build %d\n", tempheader.build); break;
2110 }
2111 case 0x180:
2112 {
2113 zprint2("Last saved in ZQuest Version: 1.80, Beta/Build %d\n", tempheader.build); break;
2114 }
2115 default:
2116 {
2117 zprint2("Last saved in ZQuest Version: %x, Beta %d\n", tempheader.zelda_version,tempheader.build); break;
2118 }
2119 */
2120 }
2121 }
2122
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 55 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
57 if(!tempheader.is_legacy() && tempheader.getAlphaVer())
2123 2 zprint2("%s\n", tempheader.getAlphaVerStr());
2124 55 else zprint2("\n");
2125
2/2
✓ Branch 0 taken 55 times.
✓ Branch 1 taken 2 times.
57 if ( tempheader.made_in_module_name[0] ) zprint2("Created with ZC Module: %s\n\n", tempheader.made_in_module_name);
2126
2/2
✓ Branch 0 taken 55 times.
✓ Branch 1 taken 2 times.
57 if ( tempheader.new_version_devsig[0] ) zprint2("Developr Signoff by: %s\n", tempheader.new_version_devsig);
2127
2/2
✓ Branch 0 taken 55 times.
✓ Branch 1 taken 2 times.
57 if ( tempheader.new_version_compilername[0] ) zprint2("Compiled with: %s, (ID: %d)\n", tempheader.new_version_compilername, tempheader.compilerid);
2128
2/2
✓ Branch 0 taken 55 times.
✓ Branch 1 taken 2 times.
57 if ( tempheader.new_version_compilerversion[0] ) zprint2("Compiler Version: %s, (%d,%d,%d,%d)\n", tempheader.new_version_compilerversion,tempheader.compilerversionnumber_first,tempheader.compilerversionnumber_second,tempheader.compilerversionnumber_third,tempheader.compilerversionnumber_fourth);
2129
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 57 times.
57 if ( tempheader.product_name[0] ) zprint2("Project ID: %s\n", tempheader.product_name);
2130
2/2
✓ Branch 0 taken 55 times.
✓ Branch 1 taken 2 times.
57 if ( tempheader.new_version_id_date_day ) zprint2("Editor Built at date and time: %d-%d-%d at @ %s %s\n", tempheader.new_version_id_date_day, tempheader.new_version_id_date_month, tempheader.new_version_id_date_year, tempheader.build_timestamp, tempheader.build_timezone);
2131 57 zprint2("\n");
2132 57 }
2133
2134 67 int32_t readheader(PACKFILE *f, zquestheader *Header, bool keepdata, byte printmetadata)
2135 {
2136 int32_t dummy;
2137 zquestheader tempheader;
2138 67 memcpy(&tempheader, Header, sizeof(tempheader));
2139 char dummybuf[80];
2140 byte temp_map_count;
2141 byte temp_midi_flags[MIDIFLAGS_SIZE];
2142 word version;
2143 char temp_pwd[30], temp_pwd2[30];
2144 int16_t temp_pwdkey;
2145 cvs_MD5Context ctx;
2146 67 memset(temp_midi_flags, 0, MIDIFLAGS_SIZE);
2147 67 memset(&tempheader, 0, sizeof(tempheader));
2148 67 memset(FFCore.quest_format, 0, sizeof(FFCore.quest_format));
2149
2150
2151
2152
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 67 times.
67 if(!pfread(tempheader.id_str,sizeof(tempheader.id_str),f,true)) // first read old header
2153 {
2154 Z_message("Unable to read header string\n");
2155 return qe_invalid;
2156 }
2157
2158 // check header
2159
1/2
✓ Branch 0 taken 67 times.
✗ Branch 1 not taken.
67 if(strcmp(tempheader.id_str,QH_NEWIDSTR))
2160 {
2161 if(strcmp(tempheader.id_str,QH_IDSTR))
2162 {
2163 Z_message("Invalid header string: '%s' (was expecting '%s' or '%s')\n", tempheader.id_str, QH_IDSTR, QH_NEWIDSTR);
2164 return qe_invalid;
2165 }
2166 }
2167
2168 67 int32_t templatepath_len=0;
2169
2170 67 tempheader.external_zinfo = false;
2171 67 read_zinfo = false;
2172
1/2
✓ Branch 0 taken 67 times.
✗ Branch 1 not taken.
67 if(!strcmp(tempheader.id_str,QH_IDSTR)) //pre-1.93 version
2173 {
2174 byte padding;
2175
2176 if(!p_getc(&padding,f,true))
2177 {
2178 return qe_invalid;
2179 }
2180
2181 if(!p_igetw(&tempheader.zelda_version,f,true))
2182 {
2183 return qe_invalid;
2184 }
2185
2186 FFCore.quest_format[vZelda] = tempheader.zelda_version;
2187
2188 if(tempheader.zelda_version > ZELDA_VERSION)
2189 {
2190 return qe_version;
2191 }
2192
2193 FFCore.quest_format[vZelda] = tempheader.zelda_version;
2194
2195 if(strcmp(tempheader.id_str,QH_IDSTR))
2196 {
2197 return qe_invalid;
2198 }
2199
2200 if(bad_version(tempheader.zelda_version))
2201 {
2202 return qe_obsolete;
2203 }
2204
2205 if(!p_igetw(&tempheader.internal,f,true))
2206 {
2207 return qe_invalid;
2208 }
2209
2210 if(!p_getc(&tempheader.quest_number,f,true))
2211 {
2212 return qe_invalid;
2213 }
2214
2215 FFCore.quest_format[qQuestNumber] = tempheader.quest_number;
2216
2217 if(!pfread(&quest_rules[0],2,f,true))
2218 {
2219 return qe_invalid;
2220 }
2221
2222 if(!p_getc(&temp_map_count,f,true))
2223 {
2224 return qe_invalid;
2225 }
2226
2227 FFCore.quest_format[qMapCount] = temp_map_count;
2228
2229 if(!p_getc(&tempheader.old_str_count,f,true))
2230 {
2231 return qe_invalid;
2232 }
2233
2234 if(!p_getc(&tempheader.data_flags[ZQ_TILES],f,true))
2235 {
2236 return qe_invalid;
2237 }
2238
2239 if(!pfread(temp_midi_flags,4,f,true))
2240 {
2241 return qe_invalid;
2242 }
2243
2244 if(!p_getc(&tempheader.data_flags[ZQ_CHEATS2],f,true))
2245 {
2246 return qe_invalid;
2247 }
2248
2249 if(!pfread(dummybuf,14,f,true))
2250 {
2251 return qe_invalid;
2252 }
2253
2254 if(!pfread(&quest_rules[2],2,f,true))
2255 {
2256 return qe_invalid;
2257 }
2258
2259 if(!p_getc(&dummybuf,f,true))
2260 {
2261 return qe_invalid;
2262 }
2263
2264 if(!pfread(tempheader.version,sizeof(tempheader.version),f,true))
2265 {
2266 return qe_invalid;
2267 }
2268
2269 if(!pfread(tempheader.title,sizeof(tempheader.title),f,true))
2270 {
2271 return qe_invalid;
2272 }
2273
2274 if(!pfread(tempheader.author,sizeof(tempheader.author),f,true))
2275 {
2276 return qe_invalid;
2277 }
2278
2279 if(!p_getc(&padding,f,true))
2280 {
2281 return qe_invalid;
2282 }
2283
2284 if(!p_igetw(&temp_pwdkey,f,true))
2285 {
2286 return qe_invalid;
2287 }
2288
2289 if(!pfread(temp_pwd,30,f,true))
2290 {
2291 return qe_invalid;
2292 }
2293
2294 get_questpwd(temp_pwd, temp_pwdkey, temp_pwd2);
2295 cvs_MD5Init(&ctx);
2296 cvs_MD5Update(&ctx, (const uint8_t*)temp_pwd2, (unsigned)strlen(temp_pwd2));
2297 cvs_MD5Final(tempheader.pwd_hash, &ctx);
2298
2299 if(tempheader.zelda_version < 0x177) // lacks new header stuff...
2300 {
2301 //memset(tempheader.minver,0,20); // char minver[9], byte build, byte foo[10]
2302 // Not anymore...
2303 memset(tempheader.minver,0,9);
2304 tempheader.build=0;
2305 tempheader.use_keyfile=0;
2306 memset(tempheader.old_foo, 0, 9);
2307 }
2308 else
2309 {
2310 if(!pfread(tempheader.minver,sizeof(tempheader.minver),f,true))
2311 {
2312 return qe_invalid;
2313 }
2314
2315 if(!p_getc(&tempheader.build,f,true))
2316 {
2317 return qe_invalid;
2318 }
2319
2320 FFCore.quest_format[vBuild] = tempheader.build;
2321
2322 if(!p_getc(&tempheader.use_keyfile,f,true))
2323 {
2324 return qe_invalid;
2325 }
2326
2327 if(!pfread(dummybuf,9,f,true))
2328 {
2329 return qe_invalid;
2330 }
2331 } // starting at minver
2332
2333 if(tempheader.zelda_version < 0x187) // lacks newer header stuff...
2334 {
2335 memset(&quest_rules[4],0,16); // word rules3..rules10
2336 }
2337 else
2338 {
2339 if(!pfread(&quest_rules[4],16,f,true)) // read new header additions
2340 {
2341 return qe_invalid; // starting at rules3
2342 }
2343
2344 if(tempheader.zelda_version <= 0x190)
2345 {
2346 set_bit(quest_rules,qr_MEANPLACEDTRAPS,0);
2347 }
2348 }
2349
2350 if((tempheader.zelda_version < 0x192)||
2351 ((tempheader.zelda_version == 0x192)&&(tempheader.build<149)))
2352 {
2353 set_bit(quest_rules,qr_BRKNSHLDTILES,(get_bit(quest_rules,qr_BRKBLSHLDS_DEP)));
2354 set_bit(deprecated_rules,qr_BRKBLSHLDS_DEP,1);
2355 }
2356
2357 if(tempheader.zelda_version >= 0x192) // lacks newer header stuff...
2358 {
2359 byte *mf=temp_midi_flags;
2360
2361 if((tempheader.zelda_version == 0x192)&&(tempheader.build<178))
2362 {
2363 mf=(byte*)dummybuf;
2364 }
2365
2366 if(!pfread(mf,32,f,true)) // read new header additions
2367 {
2368 return qe_invalid; // starting at foo2
2369 }
2370
2371 if(!pfread(dummybuf,18,f,true)) // read new header additions
2372 {
2373 return qe_invalid; // starting at foo2
2374 }
2375 }
2376
2377 if((tempheader.zelda_version < 0x192)||
2378 ((tempheader.zelda_version == 0x192)&&(tempheader.build<145)))
2379 {
2380 memset(tempheader.templatepath,0,2048);
2381 }
2382 else
2383 {
2384 if(!pfread(tempheader.templatepath,280,f,true)) // read templatepath
2385 {
2386 return qe_invalid;
2387 }
2388 }
2389
2390 if((tempheader.zelda_version < 0x192)||
2391 ((tempheader.zelda_version == 0x192)&&(tempheader.build<186)))
2392 {
2393 tempheader.use_keyfile=0;
2394 }
2395 }
2396 else
2397 {
2398 //section id
2399
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 67 times.
67 if(!p_mgetl(&dummy,f,true))
2400 {
2401 return qe_invalid;
2402 }
2403
2404 //section version info
2405
1/2
✓ Branch 0 taken 67 times.
✗ Branch 1 not taken.
67 if(!p_igetw(&version,f,true))
2406 {
2407 return qe_invalid;
2408 }
2409
2410 67 FFCore.quest_format[vHeader] = version;
2411
2412
1/2
✓ Branch 0 taken 67 times.
✗ Branch 1 not taken.
67 if(!p_igetw(&dummy,f,true))
2413 {
2414 return qe_invalid;
2415 }
2416
2417 //section size
2418
1/2
✓ Branch 0 taken 67 times.
✗ Branch 1 not taken.
67 if(!p_igetl(&dummy,f,true))
2419 {
2420 return qe_invalid;
2421 }
2422
2423 //finally... section data
2424
1/2
✓ Branch 0 taken 67 times.
✗ Branch 1 not taken.
67 if(!p_igetw(&tempheader.zelda_version,f,true))
2425 {
2426 return qe_invalid;
2427 }
2428
2429 67 FFCore.quest_format[vZelda] = tempheader.zelda_version;
2430
2431 //do some quick checking...
2432
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 67 times.
67 if(tempheader.zelda_version > ZELDA_VERSION)
2433 {
2434 return qe_version;
2435 }
2436
2437
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 67 times.
67 if(strcmp(tempheader.id_str,QH_NEWIDSTR))
2438 {
2439 return qe_invalid;
2440 }
2441
2442
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 67 times.
67 if(bad_version(tempheader.zelda_version))
2443 {
2444 return qe_obsolete;
2445 }
2446
2447
1/2
✓ Branch 0 taken 67 times.
✗ Branch 1 not taken.
67 if(!p_getc(&tempheader.build,f,true))
2448 {
2449 return qe_invalid;
2450 }
2451
2452 67 FFCore.quest_format[vBuild] = tempheader.build;
2453
2454
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 67 times.
67 if(version<3)
2455 {
2456 if(!pfread(temp_pwd,30,f,true))
2457 {
2458 return qe_invalid;
2459 }
2460
2461 if(!p_igetw(&temp_pwdkey,f,true))
2462 {
2463 return qe_invalid;
2464 }
2465
2466 get_questpwd(temp_pwd, temp_pwdkey, temp_pwd2);
2467 cvs_MD5Init(&ctx);
2468 cvs_MD5Update(&ctx, (const uint8_t*)temp_pwd2, (unsigned)strlen(temp_pwd2));
2469 cvs_MD5Final(tempheader.pwd_hash, &ctx);
2470 }
2471 else
2472 {
2473
1/2
✓ Branch 0 taken 67 times.
✗ Branch 1 not taken.
67 if(!pfread(tempheader.pwd_hash,sizeof(tempheader.pwd_hash),f,true))
2474 {
2475 return qe_invalid;
2476 }
2477 }
2478
2479
1/2
✓ Branch 0 taken 67 times.
✗ Branch 1 not taken.
67 if(!p_igetw(&tempheader.internal,f,true))
2480 {
2481 return qe_invalid;
2482 }
2483
2484
1/2
✓ Branch 0 taken 67 times.
✗ Branch 1 not taken.
67 if(!p_getc(&tempheader.quest_number,f,true))
2485 {
2486 return qe_invalid;
2487 }
2488
2489 67 FFCore.quest_format[qQuestNumber] = tempheader.quest_number;
2490
2491
1/2
✓ Branch 0 taken 67 times.
✗ Branch 1 not taken.
67 if(!pfread(tempheader.version,sizeof(tempheader.version),f,true))
2492 {
2493 return qe_invalid;
2494 }
2495
2496 //FFCore.quest_format[qQuestVersion] = tempheader.version;
2497 //needs to be copied as char[9] or stored as a s.str
2498
1/2
✓ Branch 0 taken 67 times.
✗ Branch 1 not taken.
67 if(!pfread(tempheader.minver,sizeof(tempheader.minver),f,true))
2499 {
2500 return qe_invalid;
2501 }
2502
2503 //FFCore.quest_format[qMinQuestVersion] = tempheader.minver;
2504 //needs to be copied as char[9] or stored as a s.str
2505
1/2
✓ Branch 0 taken 67 times.
✗ Branch 1 not taken.
67 if(!pfread(tempheader.title,sizeof(tempheader.title),f,true))
2506 {
2507 return qe_invalid;
2508 }
2509
2510
1/2
✓ Branch 0 taken 67 times.
✗ Branch 1 not taken.
67 if(!pfread(tempheader.author,sizeof(tempheader.author),f,true))
2511 {
2512 return qe_invalid;
2513 }
2514
2515
1/2
✓ Branch 0 taken 67 times.
✗ Branch 1 not taken.
67 if(!p_getc(&tempheader.use_keyfile,f,true))
2516 {
2517 return qe_invalid;
2518 }
2519
2520 /*
2521 if(!pfread(tempheader.data_flags,sizeof(tempheader.data_flags),f,true))
2522 {
2523 return qe_invalid;
2524 }
2525 */
2526
1/2
✓ Branch 0 taken 67 times.
✗ Branch 1 not taken.
67 if(!p_getc(&tempheader.data_flags[ZQ_TILES],f,true))
2527 {
2528 return qe_invalid;
2529 }
2530
2531
1/2
✓ Branch 0 taken 67 times.
✗ Branch 1 not taken.
67 if(!pfread(&dummybuf,4,f,true))
2532 {
2533 return qe_invalid;
2534 }
2535
2536
1/2
✓ Branch 0 taken 67 times.
✗ Branch 1 not taken.
67 if(!p_getc(&tempheader.data_flags[ZQ_CHEATS2],f,true))
2537 {
2538 return qe_invalid;
2539 }
2540
2541
1/2
✓ Branch 0 taken 67 times.
✗ Branch 1 not taken.
67 if(!pfread(dummybuf,14,f,true))
2542 {
2543 return qe_invalid;
2544 }
2545
2546 67 templatepath_len=sizeof(tempheader.templatepath);
2547
2548
1/2
✓ Branch 0 taken 67 times.
✗ Branch 1 not taken.
67 if(version==1)
2549 {
2550 templatepath_len=280;
2551 }
2552
2553
1/2
✓ Branch 0 taken 67 times.
✗ Branch 1 not taken.
67 if(!pfread(tempheader.templatepath,templatepath_len,f,true))
2554 {
2555 return qe_invalid;
2556 }
2557
2558
1/2
✓ Branch 0 taken 67 times.
✗ Branch 1 not taken.
67 if(!p_getc(&temp_map_count,f,true))
2559 {
2560 return qe_invalid;
2561 }
2562
2563
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 55 times.
67 if(version>=4)
2564 {
2565
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetl(&tempheader.new_version_id_main,f,true))
2566 {
2567 return qe_invalid;
2568 }
2569
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetl(&tempheader.new_version_id_second,f,true))
2570 {
2571 return qe_invalid;
2572 }
2573
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetl(&tempheader.new_version_id_third,f,true))
2574 {
2575 return qe_invalid;
2576 }
2577
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetl(&tempheader.new_version_id_fourth,f,true))
2578 {
2579 return qe_invalid;
2580 }
2581
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetl(&tempheader.new_version_id_alpha,f,true))
2582 {
2583 return qe_invalid;
2584 }
2585
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetl(&tempheader.new_version_id_beta,f,true))
2586 {
2587 return qe_invalid;
2588 }
2589
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetl(&tempheader.new_version_id_gamma,f,true))
2590 {
2591 return qe_invalid;
2592 }
2593
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetl(&tempheader.new_version_id_release,f,true))
2594 {
2595 return qe_invalid;
2596 }
2597
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetw(&tempheader.new_version_id_date_year,f,true))
2598 {
2599 return qe_invalid;
2600 }
2601
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&tempheader.new_version_id_date_month,f,true))
2602 {
2603 return qe_invalid;
2604 }
2605
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&tempheader.new_version_id_date_day,f,true))
2606 {
2607 return qe_invalid;
2608 }
2609
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&tempheader.new_version_id_date_hour,f,true))
2610 {
2611 return qe_invalid;
2612 }
2613
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&tempheader.new_version_id_date_minute,f,true))
2614 {
2615 return qe_invalid;
2616 }
2617
2618
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!pfread(tempheader.new_version_devsig,256,f,true))
2619 {
2620 return qe_invalid;
2621 }
2622
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!strcmp(tempheader.new_version_devsig, "Venrob"))
2623 strcpy(tempheader.new_version_devsig, "EmilyV99");
2624
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!pfread(tempheader.new_version_compilername,256,f,true))
2625 {
2626 return qe_invalid;
2627 }
2628
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!pfread(tempheader.new_version_compilerversion,256,f,true))
2629 {
2630 return qe_invalid;
2631 }
2632
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!pfread(tempheader.product_name,1024,f,true))
2633 {
2634 return qe_invalid;
2635 }
2636
2637
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&tempheader.compilerid,f,true))
2638 {
2639 return qe_invalid;
2640 }
2641
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetl(&tempheader.compilerversionnumber_first,f,true))
2642 {
2643 return qe_invalid;
2644 }
2645
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetl(&tempheader.compilerversionnumber_second,f,true))
2646 {
2647 return qe_invalid;
2648 }
2649
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetl(&tempheader.compilerversionnumber_third,f,true))
2650 {
2651 return qe_invalid;
2652 }
2653
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetl(&tempheader.compilerversionnumber_fourth,f,true))
2654 {
2655 return qe_invalid;
2656 }
2657
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetw(&tempheader.developerid,f,true))
2658 {
2659 return qe_invalid;
2660 }
2661
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!pfread(tempheader.made_in_module_name,1024,f,true))
2662 {
2663 return qe_invalid;
2664 }
2665
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!pfread(tempheader.build_datestamp,256,f,true))
2666 {
2667 return qe_invalid;
2668 }
2669
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!pfread(tempheader.build_timestamp,256,f,true))
2670 {
2671 return qe_invalid;
2672 }
2673 12 }
2674 else // <4
2675 {
2676 55 tempheader.new_version_id_main = 0;
2677 55 tempheader.new_version_id_second = 0;
2678 55 tempheader.new_version_id_third = 0;
2679 55 tempheader.new_version_id_fourth = 0;
2680 55 tempheader.new_version_id_alpha = 0;
2681 55 tempheader.new_version_id_beta = 0;
2682 55 tempheader.new_version_id_gamma = 0;
2683 55 tempheader.new_version_id_release = 0;
2684 55 tempheader.new_version_id_date_year = 0;
2685 55 tempheader.new_version_id_date_month = 0;
2686 55 tempheader.new_version_id_date_day = 0;
2687 55 tempheader.new_version_id_date_hour = 0;
2688 55 tempheader.new_version_id_date_minute = 0;
2689
2690 55 memset(tempheader.new_version_devsig, 0, 256);
2691 55 memset(tempheader.new_version_compilername, 0, 256);
2692 55 memset(tempheader.new_version_compilerversion, 0, 256);
2693 55 memset(tempheader.product_name, 0, 1024);
2694 55 strcpy(tempheader.product_name, "ZQuest Creator Suite");
2695
2696 55 tempheader.compilerid = 0;
2697 55 tempheader.compilerversionnumber_first = 0;
2698 55 tempheader.compilerversionnumber_second = 0;
2699 55 tempheader.compilerversionnumber_third = 0;
2700 55 tempheader.compilerversionnumber_fourth = 0;
2701 55 tempheader.developerid = 0;
2702
2703 55 memset(tempheader.made_in_module_name, 0, 1024);
2704 55 memset(tempheader.build_datestamp, 0, 256);
2705 55 memset(tempheader.build_timestamp, 0, 256);
2706 }
2707
2708
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 55 times.
67 if ( version >= 5 )
2709 {
2710
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!pfread(tempheader.build_timezone,6,f,true))
2711 {
2712 return qe_invalid;
2713 }
2714 12 }
2715 else // < 5
2716 {
2717 55 memset(tempheader.build_timezone, 0, 6);
2718 }
2719
2/2
✓ Branch 0 taken 55 times.
✓ Branch 1 taken 12 times.
67 if ( version >= 6 )
2720 {
2721 byte b;
2722
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&b,f,true))
2723 {
2724 return qe_invalid;
2725 }
2726 12 tempheader.external_zinfo = b?true:false;
2727 12 read_zinfo = true;
2728 12 }
2729
2730
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 55 times.
67 if(version >= 7)
2731 {
2732
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&(tempheader.new_version_is_nightly),f,true))
2733 {
2734 return qe_invalid;
2735 }
2736 12 }
2737 else
2738 {
2739 55 tempheader.new_version_is_nightly = false;
2740
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
55 if(tempheader.zelda_version < 0x255)
2741 {
2742
1/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 55 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
55 switch(tempheader.zelda_version)
2743 {
2744 case 0x254:
2745 tempheader.new_version_id_main = 2;
2746 tempheader.new_version_id_second = 54;
2747 break;
2748 case 0x250:
2749
5/16
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 13 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 5 times.
✓ Branch 11 taken 23 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 10 times.
✓ Branch 14 taken 4 times.
✗ Branch 15 not taken.
55 switch(tempheader.build)
2750 {
2751 case 19:
2752 tempheader.new_version_id_main = 2;
2753 tempheader.new_version_id_second = 50;
2754 tempheader.new_version_id_gamma = 1;
2755 break;
2756 case 20:
2757 tempheader.new_version_id_main = 2;
2758 tempheader.new_version_id_second = 50;
2759 tempheader.new_version_id_gamma = 2;
2760 break;
2761 case 21:
2762 tempheader.new_version_id_main = 2;
2763 tempheader.new_version_id_second = 50;
2764 tempheader.new_version_id_gamma = 3;
2765 break;
2766 case 22:
2767 tempheader.new_version_id_main = 2;
2768 tempheader.new_version_id_second = 50;
2769 tempheader.new_version_id_gamma = 4;
2770 break;
2771 case 23:
2772 tempheader.new_version_id_main = 2;
2773 tempheader.new_version_id_second = 50;
2774 tempheader.new_version_id_gamma = 5;
2775 break;
2776 case 24:
2777 13 tempheader.new_version_id_main = 2;
2778 13 tempheader.new_version_id_second = 50;
2779 13 tempheader.new_version_id_release = -1;
2780 13 break;
2781 case 25:
2782 tempheader.new_version_id_main = 2;
2783 tempheader.new_version_id_second = 50;
2784 tempheader.new_version_id_third = 1;
2785 tempheader.new_version_id_gamma = 1;
2786 break;
2787 case 26:
2788 tempheader.new_version_id_main = 2;
2789 tempheader.new_version_id_second = 50;
2790 tempheader.new_version_id_third = 1;
2791 tempheader.new_version_id_gamma = 2;
2792 break;
2793 case 27:
2794 tempheader.new_version_id_main = 2;
2795 tempheader.new_version_id_second = 50;
2796 tempheader.new_version_id_third = 1;
2797 tempheader.new_version_id_gamma = 3;
2798 break;
2799 case 28:
2800 5 tempheader.new_version_id_main = 2;
2801 5 tempheader.new_version_id_second = 50;
2802 5 tempheader.new_version_id_third = 1;
2803 5 tempheader.new_version_id_release = -1;
2804 5 break;
2805 case 29:
2806 23 tempheader.new_version_id_main = 2;
2807 23 tempheader.new_version_id_second = 50;
2808 23 tempheader.new_version_id_third = 2;
2809 23 tempheader.new_version_id_release = -1;
2810 23 break;
2811 case 30:
2812 tempheader.new_version_id_main = 2;
2813 tempheader.new_version_id_second = 50;
2814 tempheader.new_version_id_third = 3;
2815 tempheader.new_version_id_gamma = 1;
2816 break;
2817 case 31:
2818 10 tempheader.new_version_id_main = 2;
2819 10 tempheader.new_version_id_second = 53;
2820 10 tempheader.new_version_id_gamma = -1;
2821 10 break;
2822 case 32:
2823 4 tempheader.new_version_id_main = 2;
2824 4 tempheader.new_version_id_second = 53;
2825 4 tempheader.new_version_id_release = -1;
2826 4 break;
2827 case 33:
2828 tempheader.new_version_id_main = 2;
2829 tempheader.new_version_id_second = 53;
2830 tempheader.new_version_id_third = 1;
2831 break;
2832 }
2833 55 break;
2834
2835 case 0x211:
2836 tempheader.new_version_id_main = 2;
2837 tempheader.new_version_id_second = 11;
2838 tempheader.new_version_id_beta = tempheader.build;
2839 break;
2840 case 0x210:
2841 tempheader.new_version_id_main = 2;
2842 tempheader.new_version_id_second = 10;
2843 tempheader.new_version_id_beta = tempheader.build;
2844 break;
2845 }
2846 55 }
2847 }
2848
2/4
✓ Branch 0 taken 67 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 67 times.
67 if(printmetadata || __isZQuest)
2849 {
2850 print_quest_metadata(tempheader, loading_qst_name, loading_qst_num);
2851 }
2852 }
2853
2854 //{ Version Warning
2855 67 int32_t vercmp = tempheader.compareVer();
2856 67 int32_t astatecmp = compare(int32_t(tempheader.getAlphaState()), ALPHA_STATE);
2857 67 int32_t avercmp = compare(tempheader.getAlphaVer(), ALPHA_VER);
2858
4/6
✓ Branch 0 taken 67 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✓ Branch 3 taken 55 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 12 times.
79 if(vercmp > 0 || (!vercmp &&
2859
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 (astatecmp > 0 || (!astatecmp &&
2860 12 avercmp > 0))))
2861 {
2862 bool r = true;
2863 if(loadquest_report)
2864 {
2865 enter_sys_pal();
2866 AlertDialog("Quest saved in newer version",
2867 "This quest was last saved in a newer version of ZQuest."
2868 " Attempting to load this quest may not work correctly; to"
2869 " avoid issues, try loading this quest in at least '" + std::string(tempheader.getVerStr()) + "'"
2870 "\n\nWould you like to continue loading anyway? (Not recommended)",
2871 [&](bool ret,bool)
2872 {
2873 r = ret;
2874 }).show();
2875 exit_sys_pal();
2876 }
2877 if(!r)
2878 return qe_silenterr;
2879 }
2880
1/2
✓ Branch 0 taken 67 times.
✗ Branch 1 not taken.
67 else if(tempheader.compareDate() > 0)
2881 {
2882 bool r = true;
2883 if(loadquest_report)
2884 {
2885 enter_sys_pal();
2886 AlertDialog("Quest saved in newer build",
2887 "This quest was last saved in a newer build of ZQuest, and may have"
2888 " issues loading in this build."
2889 "\n\nWould you like to continue loading anyway?",
2890 [&](bool ret,bool)
2891 {
2892 r = ret;
2893 }).show();
2894 exit_sys_pal();
2895 }
2896 if(!r)
2897 return qe_silenterr;
2898 }
2899 //}
2900
2901 67 read_ext_zinfo = tempheader.external_zinfo;
2902
2903
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 67 times.
67 if(keepdata==true)
2904 {
2905 67 memcpy(Header, &tempheader, sizeof(tempheader));
2906 67 map_count=temp_map_count;
2907 67 memcpy(midi_flags, temp_midi_flags, MIDIFLAGS_SIZE);
2908 67 }
2909
2910 67 return 0;
2911 67 }
2912
2913 58 int32_t readrules(PACKFILE *f, zquestheader *Header, bool keepdata)
2914 {
2915 int32_t dummy;
2916 zquestheader tempheader;
2917 58 word s_version=0;
2918 58 dword compatrule_version=0;
2919
2920 58 memcpy(&tempheader, Header, sizeof(tempheader));
2921
2922
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 if(tempheader.zelda_version >= 0x193)
2923 {
2924 //section version info
2925
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(!p_igetw(&s_version,f,true))
2926 {
2927 return qe_invalid;
2928 }
2929
2930 58 FFCore.quest_format[vRules] = s_version;
2931
2932
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(!p_igetw(&dummy,f,true))
2933 {
2934 return qe_invalid;
2935 }
2936
2937
2/2
✓ Branch 0 taken 55 times.
✓ Branch 1 taken 3 times.
58 if(s_version > 16)
2938 {
2939
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_igetl(&compatrule_version,f,true))
2940 {
2941 return qe_invalid;
2942 }
2943 3 }
2944 58 FFCore.quest_format[vCompatRule] = compatrule_version;
2945
2946 //section size
2947
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(!p_igetl(&dummy,f,true))
2948 {
2949 return qe_invalid;
2950 }
2951
2952
2/2
✓ Branch 0 taken 55 times.
✓ Branch 1 taken 3 times.
58 if ( s_version < 15 )
2953 {
2954 //finally... section data
2955
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
55 if(!pfread(quest_rules,QUESTRULES_SIZE,f,true))
2956 {
2957 return qe_invalid;
2958 }
2959 55 }
2960 else
2961 {
2962
2963
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(!pfread(quest_rules,QUESTRULES_NEW_SIZE,f,true))
2964 {
2965 return qe_invalid;
2966 }
2967
2968 }
2969 58 }
2970
2971 //al_trace("Rules version %d\n", s_version);
2972 //{ bunch of compat stuff
2973 58 memcpy(deprecated_rules, quest_rules, QUESTRULES_NEW_SIZE);
2974
2975
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(s_version<2)
2976 {
2977 set_bit(quest_rules,14,0);
2978 set_bit(quest_rules,27,0);
2979 set_bit(quest_rules,28,0);
2980 set_bit(quest_rules,29,0);
2981 set_bit(quest_rules,30,0);
2982 set_bit(quest_rules,32,0);
2983 set_bit(quest_rules,36,0);
2984 set_bit(quest_rules,49,0);
2985 set_bit(quest_rules,50,0);
2986 set_bit(quest_rules,51,0);
2987 set_bit(quest_rules,68,0);
2988 set_bit(quest_rules,75,0);
2989 set_bit(quest_rules,76,0);
2990 set_bit(quest_rules,98,0);
2991 set_bit(quest_rules,110,0);
2992 set_bit(quest_rules,113,0);
2993 set_bit(quest_rules,116,0);
2994 set_bit(quest_rules,102,0);
2995 set_bit(quest_rules,132,0);
2996 }
2997
2998 //Now, do any updates...
2999
2/6
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 58 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
58 if((tempheader.zelda_version < 0x211)||((tempheader.zelda_version == 0x211)&&(tempheader.build<18)))
3000 {
3001 set_bit(quest_rules, qr_SMOOTHVERTICALSCROLLING,1);
3002 set_bit(quest_rules, qr_REPLACEOPENDOORS, 1);
3003 set_bit(quest_rules, qr_OLDLENSORDER, 1);
3004 set_bit(quest_rules, qr_NOFAIRYGUYFIRES, 1);
3005 set_bit(quest_rules, qr_TRIGGERSREPEAT, 1);
3006 }
3007
3008
2/6
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 58 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
58 if((tempheader.zelda_version < 0x193)||((tempheader.zelda_version == 0x193)&&(tempheader.build<3)))
3009 {
3010 set_bit(quest_rules,qr_WALLFLIERS,1);
3011 }
3012
3013
2/6
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 58 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
58 if((tempheader.zelda_version < 0x193)||((tempheader.zelda_version == 0x193)&&(tempheader.build<4)))
3014 {
3015 set_bit(quest_rules,qr_NOBOMBPALFLASH,1);
3016 }
3017
3018
2/6
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 58 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
58 if((tempheader.zelda_version < 0x193)||((tempheader.zelda_version == 0x193)&&(tempheader.build<3)))
3019 {
3020 set_bit(quest_rules,qr_NOSCROLLCONTINUE,1);
3021 }
3022
3023
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(tempheader.zelda_version <= 0x210)
3024 {
3025 set_bit(quest_rules,qr_ARROWCLIP,1);
3026 }
3027
3028
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(tempheader.zelda_version == 0x210)
3029 {
3030 set_bit(quest_rules, qr_NOSCROLLCONTINUE, get_bit(quest_rules, qr_CMBCYCLELAYERS));
3031 set_bit(quest_rules, qr_CMBCYCLELAYERS, 0);
3032 set_bit(quest_rules, qr_CONT_SWORD_TRIGGERS, 1);
3033 }
3034
3035
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(tempheader.zelda_version <= 0x210)
3036 {
3037 set_bit(quest_rules,qr_OLDSTYLEWARP,1);
3038 set_bit(quest_rules,qr_210_WARPRETURN,1);
3039 }
3040
3041 //might not be correct
3042
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(tempheader.zelda_version < 0x210)
3043 {
3044 set_bit(deprecated_rules, qr_OLDTRIBBLES_DEP,1);
3045 set_bit(quest_rules, qr_OLDHOOKSHOTGRAB,1);
3046 }
3047
3048
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(tempheader.zelda_version < 0x211)
3049 {
3050 set_bit(quest_rules, qr_WRONG_BRANG_TRAIL_DIR,1);
3051 }
3052
3053
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
58 if(tempheader.zelda_version == 0x192 && tempheader.build == 163)
3054 {
3055 set_bit(quest_rules, qr_192b163_WARP,1);
3056 }
3057
3058
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(tempheader.zelda_version == 0x210)
3059 {
3060 set_bit(deprecated_rules, qr_OLDTRIBBLES_DEP, get_bit(quest_rules, qr_DMGCOMBOPRI));
3061 set_bit(quest_rules, qr_DMGCOMBOPRI, 0);
3062 }
3063
3064
2/6
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 58 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
58 if(tempheader.zelda_version < 0x211 || (tempheader.zelda_version == 0x211 && tempheader.build<15))
3065 {
3066 set_bit(quest_rules, qr_OLDPICKUP,1);
3067 }
3068
3069
2/6
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 58 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
58 if(tempheader.zelda_version < 0x211 || (tempheader.zelda_version == 0x211 && tempheader.build < 18))
3070 {
3071 set_bit(quest_rules,qr_NOSOLIDDAMAGECOMBOS, 1);
3072 set_bit(quest_rules, qr_ITEMPICKUPSETSBELOW, 1); // broke around build 400
3073 }
3074
3075
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(tempheader.zelda_version < 0x250) // version<0x250 checks for beta 18; build was set to 18 prematurely
3076 {
3077 set_bit(quest_rules,qr_HOOKSHOTDOWNBUG, 1);
3078 }
3079
3080
4/4
✓ Branch 0 taken 55 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 42 times.
✓ Branch 3 taken 13 times.
58 if(tempheader.zelda_version == 0x250 && tempheader.build == 24) // Annoying...
3081 {
3082 13 set_bit(quest_rules,qr_PEAHATCLOCKVULN, 1);
3083 13 }
3084
3085
4/6
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 55 times.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 55 times.
58 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 22)) //22 is 2.50.0 RC4. Gotta set the door repair QR... -Dimi
3086 {
3087 set_bit(quest_rules,qr_OLD_DOORREPAIR, 1);
3088 }
3089
3090
4/6
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 55 times.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 55 times.
58 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 20)) //20 is 2.50.0 RC1 and RC2 (cause it didn't get bumped). Okay I'm gonna be honest I have no idea if any 2.50 build was available before RC1, but gonna try and cover my ass here -Dimi
3091 {
3092 set_bit(quest_rules,qr_OLD_SECRETMONEY, 1);
3093 }
3094
3095
5/6
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 55 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 13 times.
✓ Branch 5 taken 42 times.
58 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 28)) //28 is 2.50.1 final. Potion bug might have been used, I dunno. -Dimi
3096 {
3097 13 set_bit(quest_rules,qr_OLD_POTION_OR_HC, 1);
3098 13 }
3099
3100
5/6
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 55 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 13 times.
✓ Branch 5 taken 42 times.
58 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<28))
3101 {
3102 13 set_bit(quest_rules, qr_OFFSCREENWEAPONS, 1);
3103 13 }
3104
3105 //Bombchu fix.
3106
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 55 times.
58 if(tempheader.zelda_version == 0x250)
3107 {
3108
2/2
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 13 times.
55 if ( tempheader.build == 24 ) //2.50.0
3109 {
3110 13 set_bit(quest_rules, qr_BOMBCHUSUPERBOMB, 1);
3111 13 }
3112
2/2
✓ Branch 0 taken 50 times.
✓ Branch 1 taken 5 times.
55 if ( tempheader.build == 28 ) //2.50.1
3113 {
3114 5 set_bit(quest_rules, qr_BOMBCHUSUPERBOMB, 1);
3115 5 }
3116
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 23 times.
55 if ( tempheader.build == 29 ) //2.50.2
3117 {
3118 23 set_bit(quest_rules, qr_BOMBCHUSUPERBOMB, 0);
3119 23 }
3120
1/2
✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
55 if ( tempheader.build == 30 ) //2.50.3RC1
3121 {
3122 set_bit(quest_rules, qr_BOMBCHUSUPERBOMB, 0);
3123 }
3124 55 }
3125
3126
5/6
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 55 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 18 times.
✓ Branch 5 taken 37 times.
58 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<29))
3127 {
3128 // qr_OFFSETEWPNCOLLISIONFIX
3129 // All 'official' quests need this disabled.
3130 // All 2.10 and lower quests need this enabled to preseve compatability.
3131 // All 2.11 - 2.5.1 quests should have it set also, due to a bug in about half of all the betas.
3132
3133 //~Gleeok
3134 18 set_bit(quest_rules, qr_OFFSETEWPNCOLLISIONFIX, 1); //This has to be set!!!!
3135
3136 // Broke in build 695
3137
2/4
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 18 times.
18 if(tempheader.zelda_version>=0x211 && tempheader.build>=18)
3138 18 set_bit(quest_rules, qr_BROKENSTATUES, 1);
3139 18 }
3140
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if (tempheader.zelda_version <= 0x190)
3141 {
3142 set_bit(quest_rules, qr_COPIED_SWIM_SPRITES, 1);
3143 }
3144
6/10
✓ Branch 0 taken 55 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 3 times.
58 if ( (tempheader.zelda_version == 0x250 && tempheader.build < 33) || tempheader.zelda_version == 0x254 || tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x255 && tempheader.build < 50) )
3145 {
3146 55 set_bit(quest_rules, qr_OLD_SLASHNEXT_SECRETS, 1);
3147 55 }
3148
3149
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if ( (tempheader.zelda_version < 0x211) ) //2.10 water and ladder interaction
3150 {
3151 set_bit(quest_rules, qr_OLD_210_WATER, 1);
3152 }
3153
3154
4/6
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 55 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
58 if ( (tempheader.zelda_version < 0x255 ) || (tempheader.zelda_version == 0x255 && tempheader.build < 51 ) ) //2.10 water and ladder interaction
3155 {
3156 55 set_bit(quest_rules,qr_STEP_IS_FLOAT,0);
3157 55 }
3158
3159
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if ( tempheader.zelda_version < 0x250 )
3160 {
3161 set_bit(quest_rules, qr_8WAY_SHOT_SFX, 1);
3162 }
3163
3164
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(s_version < 3)
3165 {
3166 set_bit(quest_rules, qr_HOLDNOSTOPMUSIC, 1);
3167 set_bit(quest_rules, qr_CAVEEXITNOSTOPMUSIC, 1);
3168 }
3169
3170
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(s_version<4)
3171 {
3172 set_bit(quest_rules,10,0);
3173 }
3174
3175
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(s_version<5)
3176 {
3177 set_bit(quest_rules,27,0);
3178 }
3179
3180
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(s_version<6)
3181 {
3182 set_bit(quest_rules,46,0);
3183 }
3184
3185
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(s_version<7) // January 2008
3186 {
3187 set_bit(quest_rules,qr_HEARTSREQUIREDFIX,0);
3188 set_bit(quest_rules,qr_PUSHBLOCKCSETFIX,1);
3189 }
3190
3191
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 if(s_version<8)
3192 {
3193 set_bit(quest_rules, 12, 0);
3194 }
3195 else
3196 {
3197 58 set_bit(deprecated_rules, 12, 0);
3198 }
3199
3200
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(s_version<9) // October 2008
3201 {
3202 set_bit(quest_rules,qr_NOROPE2FLASH_DEP,0);
3203 set_bit(quest_rules,qr_NOBUBBLEFLASH_DEP,0);
3204 set_bit(quest_rules,qr_GHINI2BLINK_DEP,0);
3205 set_bit(quest_rules,qr_PHANTOMGHINI2_DEP,0);
3206 }
3207
3208
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(s_version<10) // December 2008
3209 {
3210 set_bit(quest_rules,qr_NOCLOCKS_DEP,0);
3211 set_bit(quest_rules, qr_ALLOW10RUPEEDROPS_DEP,0);
3212 }
3213
3214
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(s_version<11) // April 2009
3215 {
3216 set_bit(quest_rules,qr_SLOWENEMYANIM_DEP,0);
3217 }
3218
3219
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(s_version<12) // December 2009
3220 {
3221 set_bit(quest_rules,qr_BRKBLSHLDS_DEP,0);
3222 set_bit(quest_rules, qr_OLDTRIBBLES_DEP,0);
3223 }
3224
3225 //if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 24))
3226
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(s_version < 13)
3227 {
3228 set_bit(quest_rules,qr_SHOPCHEAT, 1);
3229 }
3230
3231 // Not entirely sure this is the best place for this...
3232 //2.50.2 bitmap offset fix
3233 58 memset(extra_rules, 0, EXTRARULES_SIZE);
3234
5/6
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 55 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 18 times.
✓ Branch 5 taken 37 times.
58 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<29))
3235 {
3236 18 set_bit(extra_rules, er_BITMAPOFFSET, 1);
3237 18 set_bit(quest_rules, qr_BITMAPOFFSETFIX, 1);
3238 18 }
3239 //required because quest templates also used this bit, although
3240 //it never did anything, before. -Z
3241
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 55 times.
58 if ( tempheader.zelda_version == 0x250 )
3242 {
3243
5/6
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 23 times.
✓ Branch 2 taken 32 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 10 times.
✓ Branch 5 taken 22 times.
55 if( tempheader.build == 29 || tempheader.build == 30 || tempheader.build == 31 )
3244 {
3245 33 set_bit(extra_rules, er_BITMAPOFFSET, 0);
3246 33 set_bit(quest_rules, qr_BITMAPOFFSETFIX, 0);
3247 33 }
3248 55 }
3249
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if ( tempheader.zelda_version == 0x254 )
3250 {
3251 set_bit(extra_rules, er_BITMAPOFFSET, 0);
3252 set_bit(quest_rules, qr_BITMAPOFFSETFIX, 0);
3253 }
3254
3/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 55 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
58 if ( tempheader.zelda_version == 0x255 && tempheader.build < 42 ) //QR was added to 255 in this build.
3255 {
3256 set_bit(extra_rules, er_BITMAPOFFSET, 0);
3257 set_bit(quest_rules, qr_BITMAPOFFSETFIX, 0);
3258 }
3259 //optimise fast drawing for older versions.
3260
4/6
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 55 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
58 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 42) )
3261 {
3262 55 set_bit(quest_rules, qr_OLDSPRITEDRAWS, 1);
3263 55 }
3264 //Old eweapon->Parent (was added in 2.54, Alpha 19)
3265 //The change was made in build 43, but I'm setting this to < 42, because quests made in 42 would benefit from this change, and
3266 //older quests can set the rule by hand. We need a new qst.dat again.
3267
4/6
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 55 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
58 if ( tempheader.zelda_version == 0x254 || (tempheader.zelda_version == 0x255 && tempheader.build < 42) )
3268 {
3269 set_bit(quest_rules, qr_OLDEWPNPARENT, 1);
3270 }
3271
4/6
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 55 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
58 if ( tempheader.zelda_version == 0x254 || (tempheader.zelda_version == 0x255 && tempheader.build < 44) )
3272 {
3273 set_bit(quest_rules, qr_OLDCREATEBITMAP_ARGS, 1);
3274 }
3275
4/6
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 55 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
58 if ( tempheader.zelda_version == 0x254 || (tempheader.zelda_version == 0x255 && tempheader.build < 45) )
3276 {
3277 set_bit(quest_rules, qr_OLDQUESTMISC, 1);
3278 }
3279
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 55 times.
58 if ( tempheader.zelda_version < 0x254 )
3280 {
3281 55 set_bit(quest_rules, qr_OLDCREATEBITMAP_ARGS, 0);
3282 55 set_bit(quest_rules, qr_OLDEWPNPARENT, 0);
3283 55 set_bit(quest_rules, qr_OLDQUESTMISC, 0);
3284 55 }
3285
3286 //item scripts continue to run
3287
4/6
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 55 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
58 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 44) )
3288 {
3289 55 set_bit(quest_rules, qr_ITEMSCRIPTSKEEPRUNNING, 0);
3290 55 set_bit(quest_rules, qr_SCRIPTSRUNINHEROSTEPFORWARD, 0);
3291 55 set_bit(quest_rules, qr_FIXSCRIPTSDURINGSCROLLING, 0);
3292 55 set_bit(quest_rules, qr_SCRIPTDRAWSINWARPS, 0);
3293 55 set_bit(quest_rules, qr_DYINGENEMYESDONTHURTHERO, 0);
3294 55 set_bit(quest_rules, qr_OUTOFBOUNDSENEMIES, 0);
3295 55 set_bit(quest_rules, qr_SPRITEXY_IS_FLOAT, 0);
3296 55 }
3297
3298
4/6
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 55 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
58 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 46) )
3299 {
3300 55 set_bit(quest_rules, qr_CLEARINITDONSCRIPTCHANGE, 1);
3301 55 }
3302
4/6
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 55 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
58 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 46) )
3303 {
3304 55 set_bit(quest_rules, qr_TRACESCRIPTIDS, 0);
3305 55 set_bit(quest_rules, qr_SCRIPT_FRIENDLY_ENEMY_TYPES, 1);
3306 55 set_bit(quest_rules, qr_PARSER_BOOL_TRUE_DECIMAL, 1);
3307 55 set_bit(quest_rules,qr_PARSER_250DIVISION,1);
3308 55 set_bit(quest_rules,qr_PARSER_BOOL_TRUE_DECIMAL,1);
3309 55 set_bit(quest_rules,qr_PARSER_TRUE_INT_SIZE,0);
3310 55 set_bit(quest_rules,qr_PARSER_FORCE_INLINE,0);
3311 55 set_bit(quest_rules,qr_PARSER_BINARY_32BIT,0);
3312
1/2
✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
55 if ( get_bit(quest_rules, qr_SELECTAWPN) )
3313 {
3314 set_bit(quest_rules,qr_NO_L_R_BUTTON_INVENTORY_SWAP,1);
3315 //In < 2.55a27, if you had an A+B subscreen, L and R didn't shift through inventory.
3316 //Now they **do**, unless you disable that behaviour.
3317 //For the sake of compatibility, old quests with the A+B subscreen rule enabed
3318 //now enable the disable L/R item swap on load.
3319 }
3320
3321 55 }
3322
4/6
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 55 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
58 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 47) )
3323 {
3324 //Compatibility: Setting the hero's action to rafting was previously disallowed, though legal for scripts to attempt.
3325 55 set_bit(quest_rules, qr_DISALLOW_SETTING_RAFTING, 1);
3326 //Compatibility: The calculation for when to loop an animation did not factor in ASkipY correctly, resulting in
3327 //animations ending earlier than they should.
3328 55 set_bit(quest_rules, qr_BROKEN_ASKIP_Y_FRAMES, 1);
3329 //Enemies would ignore solidity on the top half of combos
3330 55 set_bit(quest_rules, qr_ENEMY_BROKEN_TOP_HALF_SOLIDITY, 1);
3331 //Ceiling collison was a bit wonky, including hitting your head before you are near the ceiling or clipping into it slightly.
3332 55 set_bit(quest_rules, qr_OLD_SIDEVIEW_CEILING_COLLISON, 1);
3333 //If an itemdata had a 'frames' of 0, items created of that data would ignore all changes to 'frames'
3334 55 set_bit(quest_rules, qr_0AFRAME_ITEMS_IGNORE_AFRAME_CHANGES, 1);
3335 //Collision used some odd calculations before, and enemies could not be hit back into the top row or left column
3336 55 set_bit(quest_rules, qr_OLD_ENEMY_KNOCKBACK_COLLISION, 1);
3337 55 }
3338
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 55 times.
58 if ( tempheader.zelda_version < 0x255 )
3339 {
3340 55 set_bit(quest_rules, qr_NOFFCWAITDRAW, 1);
3341 55 set_bit(quest_rules, qr_NOITEMWAITDRAW, 1);
3342 55 set_bit(quest_rules, qr_SETENEMYWEAPONSPRITESONWPNCHANGE, 1);
3343 55 set_bit(quest_rules, qr_OLD_INIT_SCRIPT_TIMING, 1);
3344 //set_bit(quest_rules, qr_DO_NOT_DEALLOCATE_INIT_AND_SAVELOAD_ARRAYS, 1);
3345 55 }
3346
4/6
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 55 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
58 if ( tempheader.zelda_version < 0x255 || ( tempheader.zelda_version == 0x255 && tempheader.build < 48 ) )
3347 {
3348 55 set_bit(quest_rules, qr_SETENEMYWEAPONSPRITESONWPNCHANGE, 1);
3349 55 }
3350
4/6
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 55 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
58 if( tempheader.zelda_version < 0x255 || ( tempheader.zelda_version == 0x255 && tempheader.build < 52 ) )
3351 {
3352 55 set_bit(quest_rules, qr_OLD_PRINTF_ARGS, 1);
3353 55 }
3354
3355
3356
4/6
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 55 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
58 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 54) )
3357 {
3358 55 set_bit(quest_rules, qr_BROKEN_RING_POWER, 1);
3359 55 }
3360
4/6
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 55 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
58 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 56) )
3361 {
3362 55 set_bit(quest_rules, qr_NO_OVERWORLD_MAP_CHARTING, 1);
3363 55 }
3364
4/6
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 55 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
58 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 57) )
3365 {
3366 55 set_bit(quest_rules, qr_DUNGEONS_USE_CLASSIC_CHARTING, 1);
3367 55 }
3368
4/6
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 55 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
58 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 58) )
3369 {
3370 //Rule used to be 'qr_SETXYBUTTONITEMS', now split.
3371
1/2
✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
55 if(get_bit(quest_rules,qr_SET_XBUTTON_ITEMS))
3372 set_bit(quest_rules,qr_SET_YBUTTON_ITEMS,1);
3373 55 }
3374
4/6
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 55 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
58 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 59) )
3375 {
3376 55 set_bit(quest_rules,qr_ALLOW_EDITING_COMBO_0,1);
3377 55 }
3378
4/6
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 55 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
58 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 60) )
3379 {
3380 55 set_bit(quest_rules,qr_OLD_CHEST_COLLISION,1);
3381 55 }
3382
3383
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 55 times.
58 if ( tempheader.zelda_version < 0x254 )
3384 {
3385 55 set_bit(quest_rules, qr_250WRITEEDEFSCRIPT, 1);
3386 55 }
3387 //Sideview spikes in 2.50.0
3388
5/6
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 55 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 13 times.
✓ Branch 5 taken 42 times.
58 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<27)) //2.50.1RC3
3389 {
3390 13 set_bit(quest_rules, qr_OLDSIDEVIEWSPIKES, 1);
3391 13 }
3392 //more 2.50 fixes -Z
3393
5/6
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 55 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 41 times.
✓ Branch 5 taken 14 times.
58 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<31))
3394 {
3395 41 set_bit(quest_rules, qr_MELEEMAGICCOST, 0);
3396 41 set_bit(quest_rules, qr_GANONINTRO, 0); //This will get flipped later on in the compatrule 11 check. That's why it's turning it off.
3397 41 set_bit(quest_rules, qr_OLDMIRRORCOMBOS, 1);
3398 41 set_bit(quest_rules, qr_BROKENBOOKCOST, 1);
3399 41 set_bit(quest_rules, qr_BROKENCHARINTDRAWING, 1);
3400
3401 41 }
3402
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
58 if(tempheader.zelda_version == 0x254 && tempheader.build<41)
3403 {
3404 //set_bit(quest_rules,qr_MELEEMAGICCOST, get_bit(extra_rules,er_MAGICCOSTSWORD));
3405 set_bit(quest_rules,qr_MELEEMAGICCOST, 1);
3406 }
3407
3408
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(tempheader.zelda_version < 0x193)
3409 {
3410 set_bit(quest_rules, qr_SHORTDGNWALK, 1);
3411 }
3412
3413
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 55 times.
58 if(tempheader.zelda_version < 0x255)
3414 {
3415 55 set_bit(quest_rules, qr_OLDINFMAGIC, 1);
3416 55 }
3417
3418
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if((tempheader.zelda_version < 0x250)) //2.10 and earlier allowed the triforce to Warp Player out of Item Cellars in Dungeons. -Z (15th March, 2019 )
3419 {
3420 set_bit(quest_rules,qr_SIDEVIEWTRIFORCECELLAR,1);
3421 }
3422
3423
4/6
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 55 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
58 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 47) )
3424 {
3425 55 set_bit(quest_rules,qr_OLD_F6,1);
3426 55 }
3427
4/6
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 55 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
58 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 49) )
3428 {
3429 55 set_bit(quest_rules,qr_NO_OVERWRITING_HOPPING,1);
3430 55 }
3431
4/6
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 55 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
58 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 50) )
3432 {
3433 55 set_bit(quest_rules,qr_STRING_FRAME_OLD_WIDTH_HEIGHT,1);
3434 55 }
3435
4/6
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 55 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
58 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 53) )
3436 {
3437 55 set_bit(quest_rules,qr_BROKEN_OVERWORLD_MINIMAP,1);
3438 55 }
3439 //}
3440
3441
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 55 times.
58 if(compatrule_version < 1)
3442 {
3443 //Enemies->Secret only affects flag 16-31
3444 55 set_bit(quest_rules,qr_ENEMIES_SECRET_ONLY_16_31,1);
3445 55 }
3446
3447
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 55 times.
58 if(compatrule_version < 2)
3448 {
3449 //Old CSet2 Handling
3450 55 set_bit(quest_rules,qr_OLDCS2,1);
3451 55 }
3452
3453
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 55 times.
58 if(compatrule_version < 3)
3454 {
3455 //Hardcoded Shadow/Spawn/Death anim frames
3456 55 set_bit(quest_rules,qr_HARDCODED_ENEMY_ANIMS,1);
3457 55 }
3458
3459
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 55 times.
58 if(compatrule_version < 4)
3460 {
3461 //Hardcoded Shadow/Spawn/Death anim frames
3462 55 set_bit(quest_rules,qr_OLD_ITEMDATA_SCRIPT_TIMING,1);
3463 55 }
3464
3465
3/4
✓ Branch 0 taken 55 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 55 times.
58 if(compatrule_version < 5 && tempheader.zelda_version >= 0x250)
3466 {
3467 //Hardcoded Shadow/Spawn/Death anim frames
3468 55 set_bit(quest_rules,qr_NO_LANMOLA_RINGLEADER,1);
3469 55 }
3470
3471
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 55 times.
58 if(compatrule_version < 6)
3472 {
3473 //Step->Secret (Temp) only affects flag 16-31
3474 55 set_bit(quest_rules,qr_STEPTEMP_SECRET_ONLY_16_31,1);
3475 55 }
3476
3477
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 55 times.
58 if(compatrule_version < 7)
3478 {
3479 //'Hit All Triggers->Perm Secret' doesn't trigger temp secrets
3480 55 set_bit(quest_rules,qr_ALLTRIG_PERMSEC_NO_TEMP,1);
3481 55 }
3482
3483
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 55 times.
58 if(compatrule_version < 8)
3484 {
3485 //Hardcoded LItem/Bomb/Clock/Magic Tile Mods
3486 55 set_bit(quest_rules,qr_HARDCODED_LITEM_LTMS,1);
3487 55 }
3488
3489
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 55 times.
58 if(compatrule_version < 9)
3490 {
3491 //Hardcoded BS Patras
3492 55 set_bit(quest_rules,qr_HARDCODED_BS_PATRA,1);
3493 //Hardcoded Patra Inner Eye offsets
3494 55 set_bit(quest_rules,qr_PATRAS_USE_HARDCODED_OFFSETS,1);
3495 //Broken 'Big enemy' animation style
3496 55 set_bit(quest_rules,qr_BROKEN_BIG_ENEMY_ANIMATION,1);
3497 //Broken Attribute 31/32
3498 55 set_bit(quest_rules,qr_BROKEN_ATTRIBUTE_31_32,1);
3499 55 }
3500
3501
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 55 times.
58 if(compatrule_version < 10)
3502 {
3503 //Shared candle use limits
3504 55 set_bit(quest_rules,qr_CANDLES_SHARED_LIMIT,1);
3505 55 }
3506
3507
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 55 times.
58 if(compatrule_version < 11)
3508 {
3509 //No cross-screen return points
3510 55 set_bit(quest_rules,qr_OLD_RESPAWN_POINTS,1);
3511 55 }
3512
3513
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 55 times.
58 if(compatrule_version < 12)
3514 {
3515 //Old fire trail duration
3516 55 set_bit(quest_rules,qr_OLD_FLAMETRAIL_DURATION,1);
3517 //Old Intro String in Ganon Room Behavior
3518
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
55 if(get_bit(quest_rules,qr_GANONINTRO)) set_bit(quest_rules,qr_GANONINTRO,0);
3519 55 else set_bit(quest_rules,qr_GANONINTRO,1);
3520 55 }
3521
3522
3/4
✓ Branch 0 taken 55 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 55 times.
✗ Branch 3 not taken.
58 if(compatrule_version < 13 && tempheader.zelda_version >= 0x255)
3523 {
3524 //ANone doesn't reset to originaltile
3525 set_bit(quest_rules,qr_ANONE_NOANIM,1);
3526 }
3527
3528
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 55 times.
58 if(compatrule_version < 14)
3529 {
3530 //Old Bridge Combo Behavior
3531 55 set_bit(quest_rules,qr_OLD_BRIDGE_COMBOS,1);
3532 55 }
3533
3534
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 55 times.
58 if(compatrule_version < 15)
3535 {
3536 //Broken Z3 Animation
3537 55 set_bit(quest_rules,qr_BROKEN_Z3_ANIMATION,1);
3538 55 }
3539
3540
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 55 times.
58 if(compatrule_version < 16)
3541 {
3542 //Old Enemy Tile Behavior with Animation (None) Enemies
3543 55 set_bit(quest_rules,qr_OLD_TILE_INITIALIZATION,1);
3544 55 }
3545
3546
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 55 times.
58 if(compatrule_version < 17)
3547 {
3548 //Old Quake/DrawYOffset behavior
3549 //set_bit(quest_rules,qr_OLD_DRAWOFFSET,1);
3550 //I'm leaving this commented cause I doubt it'll break anything and I think the bugfix might be appreciated in older versions.
3551 //On the offchance that it *does* break old quests, fixing it is as simple as uncommenting the set_bit above.
3552 55 }
3553
3554
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 55 times.
58 if(compatrule_version < 18)
3555 {
3556 //Broken DrawScreen Derivative Functions
3557 55 set_bit(quest_rules,qr_BROKEN_DRAWSCREEN_FUNCTIONS,1);
3558 //Scrolling Cancels Charge
3559 55 set_bit(quest_rules,qr_SCROLLING_KILLS_CHARGE,1);
3560 55 }
3561
3562
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 55 times.
58 if(compatrule_version < 19)
3563 {
3564 //Broken Enemy Item Carrying with Large Enemies
3565 55 set_bit(quest_rules,qr_BROKEN_ITEM_CARRYING,1);
3566 55 }
3567
3568
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 55 times.
58 if(compatrule_version < 20)
3569 {
3570 55 set_bit(quest_rules,qr_CUSTOMWEAPON_IGNORE_COST,1);
3571 55 }
3572
3573
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 55 times.
58 if(compatrule_version < 21)
3574 {
3575 55 set_bit(quest_rules,qr_LEEVERS_DONT_OBEY_STUN,1);
3576 55 set_bit(quest_rules,qr_GANON_CANT_SPAWN_ON_CONTINUE,1);
3577 55 set_bit(quest_rules,qr_WIZZROBES_DONT_OBEY_STUN,1);
3578 55 set_bit(quest_rules,qr_OLD_BUG_NET,1);
3579 55 set_bit(quest_rules,qr_MANHANDLA_BLOCK_SFX,1);
3580 55 }
3581
3582
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 55 times.
58 if(compatrule_version < 22)
3583 {
3584 55 set_bit(quest_rules,qr_BROKEN_KEEPOLD_FLAG,1);
3585 55 }
3586
3587
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 55 times.
58 if(compatrule_version < 23)
3588 {
3589 55 set_bit(quest_rules,qr_OLD_HALF_MAGIC,1);
3590 55 }
3591
3592
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 55 times.
58 if(compatrule_version < 24)
3593 {
3594 55 set_bit(quest_rules,qr_WARPS_RESTART_DMAPSCRIPT,1);
3595 55 set_bit(quest_rules,qr_DMAP_0_CONTINUE_BUG,1);
3596 55 }
3597
3598
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 55 times.
58 if(compatrule_version < 25)
3599 {
3600
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
55 if (get_bit(quest_rules, qr_OLD_FAIRY_LIMIT)) set_bit(quest_rules,qr_OLD_FAIRY_LIMIT,0);
3601 55 else set_bit(quest_rules,qr_OLD_FAIRY_LIMIT,1);
3602 55 set_bit(quest_rules,qr_OLD_SCRIPTED_KNOCKBACK,1);
3603 55 }
3604
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 55 times.
58 if(compatrule_version < 26)
3605 {
3606 55 set_bit(quest_rules,qr_OLD_KEESE_Z_AXIS,1);
3607 55 set_bit(quest_rules,qr_POLVIRE_NO_SHADOW,1);
3608 55 set_bit(quest_rules,qr_SUBSCR_OLD_SELECTOR,1);
3609 55 }
3610
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 55 times.
58 if(compatrule_version < 27) //Noticed some junk data in the QR array...
3611 {
3612
2/2
✓ Branch 0 taken 16555 times.
✓ Branch 1 taken 55 times.
16610 for(auto q = qr_POLVIRE_NO_SHADOW+1; q < qr_PARSER_250DIVISION; ++q)
3613 16555 set_bit(quest_rules,q,0);
3614
2/2
✓ Branch 0 taken 6160 times.
✓ Branch 1 taken 55 times.
6215 for(auto q = qr_COMBODATA_INITD_MULT_TENK+1; q < QUESTRULES_NEW_SIZE*8; ++q)
3615 6160 set_bit(quest_rules,q,0);
3616 //This should nuke any remaining junk data... not sure if it affected anything previous. -Em
3617 55 }
3618
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 55 times.
58 if(compatrule_version < 28)
3619 {
3620 55 set_bit(quest_rules,qr_SUBSCR_BACKWARDS_ID_ORDER,1);
3621 55 }
3622
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 55 times.
58 if(compatrule_version < 29)
3623 {
3624 55 set_bit(quest_rules,qr_OLD_LOCKBLOCK_COLLISION,1);
3625 55 }
3626
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 55 times.
58 if(compatrule_version < 30)
3627 {
3628 55 set_bit(quest_rules,qr_DECO_2_YOFFSET,1);
3629 55 set_bit(quest_rules,qr_SCREENSTATE_80s_BUG,1);
3630 55 }
3631
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 55 times.
58 if(compatrule_version < 31)
3632 {
3633 55 set_bit(quest_rules,qr_GOHMA_UNDAMAGED_BUG,1);
3634 55 set_bit(quest_rules,qr_FFCPRELOAD_BUGGED_LOAD,1);
3635 55 }
3636
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 55 times.
58 if(compatrule_version < 32)
3637 {
3638 55 set_bit(quest_rules,qr_BROKEN_GETPIXEL_VALUE,1);
3639 55 }
3640
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 55 times.
58 if(compatrule_version < 33)
3641 {
3642 55 set_bit(quest_rules,qr_NO_LIFT_SPRITE,1);
3643 55 }
3644
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 57 times.
58 if(compatrule_version < 34)
3645 {
3646 57 set_bit(quest_rules,qr_OLD_SIDEVIEW_LANDING_CODE,1);
3647 57 set_bit(quest_rules,qr_OLD_FFC_SPEED_CAP,1);
3648 57 set_bit(quest_rules,qr_OLD_FFC_FUNCTIONALITY,1);
3649 57 set_bit(quest_rules,qr_OLD_WIZZROBE_SUBMERGING,1);
3650 57 }
3651
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 if(compatrule_version < 35)
3652 {
3653 // Leaving this commented for now, might need to enable later -Em
3654 // set_bit(quest_rules,qr_ZS_NO_NEG_ARRAY,1);
3655 58 }
3656
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 if(compatrule_version < 36)
3657 {
3658 58 set_bit(quest_rules,qr_OLD_SHALLOW_SFX,1);
3659 58 }
3660
3661 //always set
3662 58 set_bit(quest_rules,qr_ANIMATECUSTOMWEAPONS,0);
3663
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 55 times.
58 if (s_version < 16) set_bit(quest_rules,qr_BROKEN_HORIZONTAL_WEAPON_ANIM,1);
3664
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 if(keepdata==true)
3665 {
3666 58 memcpy(Header, &tempheader, sizeof(tempheader));
3667 58 }
3668 58 return 0;
3669 58 }
3670
3671 478277 void init_msgstr(MsgStr *str)
3672 {
3673 478277 str->s = "";
3674 478277 str->s.shrink_to_fit();
3675 478277 str->nextstring=0;
3676 478277 str->tile=0;
3677 478277 str->cset=0;
3678 478277 str->trans=false;
3679 478277 str->font=font_zfont;
3680 478277 str->y=32;
3681 478277 str->sfx=18;
3682 478277 str->listpos=0;
3683 478277 str->x=24;
3684 478277 str->w=get_bit(quest_rules,qr_STRING_FRAME_OLD_WIDTH_HEIGHT)!=0 ? 24*8 : 26*8;
3685 478277 str->h=get_bit(quest_rules,qr_STRING_FRAME_OLD_WIDTH_HEIGHT)!=0 ? 3*8 : 5*8;
3686 478277 str->hspace=0;
3687 478277 str->vspace=0;
3688 478277 str->stringflags=0;
3689 478277 str->margins[up] = 8;
3690 478277 str->margins[down] = 0;
3691 478277 str->margins[left] = 8;
3692 478277 str->margins[right] = 0;
3693 478277 str->portrait_tile = 0;
3694 478277 str->portrait_cset = 0;
3695 478277 str->portrait_x = 0;
3696 478277 str->portrait_y = 0;
3697 478277 str->portrait_tw = 1;
3698 478277 str->portrait_th = 1;
3699 478277 str->shadow_type = 0;
3700 478277 str->shadow_color = 0;
3701 478277 str->drawlayer = 6;
3702 478277 }
3703
3704 58 void init_msgstrings(int32_t start, int32_t end)
3705 {
3706
2/4
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 58 times.
58 if(end <= start || end-start > msg_strings_size)
3707 return;
3708
3709
2/2
✓ Branch 0 taken 475136 times.
✓ Branch 1 taken 58 times.
475194 for(int32_t i=start; i<end; i++)
3710 {
3711 475136 init_msgstr(&MsgStrings[i]);
3712 475136 MsgStrings[i].listpos=i;
3713 475136 }
3714
3715
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(start==0)
3716 {
3717 58 MsgStrings[0].s = "(None)";
3718 58 MsgStrings[0].listpos = 0;
3719 58 }
3720 58 }
3721
3722 58 int32_t readstrings(PACKFILE *f, zquestheader *Header, bool keepdata)
3723 {
3724 58 MsgStr tempMsgString;
3725
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 init_msgstr(&tempMsgString);
3726
3727 58 word temp_msg_count=0;
3728 word temp_expansion[16];
3729 58 memset(temp_expansion, 0, 16*sizeof(word));
3730 58 char buf[8193] = {0};
3731
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 if(Header->zelda_version < 0x193)
3732 {
3733 byte tempbyte;
3734 int32_t strings_to_read=0;
3735 set_bit(quest_rules,qr_OLD_STRING_EDITOR_MARGINS,true);
3736 if((Header->zelda_version < 0x192)||
3737 ((Header->zelda_version == 0x192)&&(Header->build<31)))
3738 {
3739 strings_to_read=128;
3740 temp_msg_count=Header->old_str_count;
3741
3742 // Some sort of string count corruption seems to be common in old quests
3743 if(temp_msg_count>128)
3744 {
3745 temp_msg_count=128;
3746 }
3747 }
3748 else if((Header->zelda_version == 0x192)&&(Header->build<140))
3749 {
3750 strings_to_read=255;
3751 temp_msg_count=Header->old_str_count;
3752 }
3753 else
3754 {
3755 if(!p_igetw(&temp_msg_count,f,true))
3756 {
3757 return qe_invalid;
3758 }
3759
3760 strings_to_read=temp_msg_count;
3761
3762 if(temp_msg_count >= msg_strings_size)
3763 {
3764 Z_message("Reallocating string buffer...\n");
3765
3766 // if((MsgStrings=(MsgStr*)_al_sane_realloc(MsgStrings,sizeof(MsgStr)*MAXMSGS))==NULL)
3767 // return qe_nomem;
3768
3769 //memset(MsgStrings, 0, sizeof(MsgStr)*MAXMSGS);
3770 delete[] MsgStrings;
3771 MsgStrings = new MsgStr[MAXMSGS];
3772 msg_strings_size = MAXMSGS;
3773 for(auto q = 0; q < msg_strings_size; ++q)
3774 {
3775 MsgStrings[q].clear();
3776 }
3777 }
3778 }
3779
3780 //reset the message strings
3781 if(keepdata)
3782 {
3783 init_msgstrings(0,msg_strings_size);
3784 }
3785
3786 for(int32_t x=0; x<strings_to_read; x++)
3787 {
3788 init_msgstr(&tempMsgString);
3789
3790 if(!pfread(buf,73,f,true))
3791 {
3792 return qe_invalid;
3793 }
3794
3795 buf[74] = '\0';
3796 tempMsgString.s = buf;
3797
3798 if(!p_getc(&tempbyte,f,true))
3799 {
3800 return qe_invalid;
3801 }
3802
3803 if((Header->zelda_version < 0x192)||
3804 ((Header->zelda_version == 0x192)&&(Header->build<148)))
3805 {
3806 tempMsgString.nextstring=tempbyte?x+1:0;
3807
3808 if(!p_getc(&tempbyte,f,true))
3809 {
3810 return qe_invalid;
3811 }
3812
3813 if(!p_getc(&tempbyte,f,true))
3814 {
3815 return qe_invalid;
3816 }
3817 }
3818 else
3819 {
3820 if(!p_igetw(&tempMsgString.nextstring,f,true))
3821 {
3822 return qe_invalid;
3823 }
3824
3825 if(!pfread(temp_expansion,32,f,true))
3826 {
3827 return qe_invalid;
3828 }
3829 }
3830
3831 if(keepdata==true)
3832 {
3833 MsgStrings[x] = tempMsgString;
3834 }
3835 }
3836 }
3837 else
3838 {
3839 int32_t dummy_int;
3840 word s_version;
3841 word s_cversion;
3842
3843 //section version info
3844
2/4
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 58 times.
✗ Branch 3 not taken.
58 if(!p_igetw(&s_version,f,true))
3845 {
3846 return qe_invalid;
3847 }
3848
3849 58 FFCore.quest_format[vStrings] = s_version;
3850
3851
2/4
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 58 times.
✗ Branch 3 not taken.
58 if(!p_igetw(&s_cversion,f,true))
3852 {
3853 return qe_invalid;
3854 }
3855
3856 //al_trace("Strings version %d\n", s_version);
3857 //section size
3858
2/4
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 58 times.
✗ Branch 3 not taken.
58 if(!p_igetl(&dummy_int,f,true))
3859 {
3860 return qe_invalid;
3861 }
3862
3863 //finally... section data
3864
2/4
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 58 times.
✗ Branch 3 not taken.
58 if(!p_igetw(&temp_msg_count,f,true))
3865 {
3866 return qe_invalid;
3867 }
3868
3869
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 if(temp_msg_count >= msg_strings_size)
3870 {
3871 Z_message("Reallocating string buffer...\n");
3872
3873 // if((MsgStrings=(MsgStr*)_al_sane_realloc(MsgStrings,sizeof(MsgStr)*MAXMSGS))==NULL)
3874 // return qe_nomem;
3875 delete[] MsgStrings;
3876 MsgStrings = new MsgStr[MAXMSGS];
3877 msg_strings_size = MAXMSGS;
3878 for(auto q = 0; q < msg_strings_size; ++q)
3879 {
3880 MsgStrings[q].clear();
3881 }
3882 //memset(MsgStrings, 0, sizeof(MsgStr)*MAXMSGS);
3883 }
3884
3885 //reset the message strings
3886
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(keepdata)
3887 {
3888
2/2
✓ Branch 0 taken 55 times.
✓ Branch 1 taken 3 times.
58 if(s_version < 7)
3889
1/2
✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
55 set_bit(quest_rules,qr_OLD_STRING_EDITOR_MARGINS,true);
3890
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 init_msgstrings(0,msg_strings_size);
3891 58 }
3892
3893 58 int32_t string_length=(s_version<2)?73:145;
3894
3895
2/2
✓ Branch 0 taken 3083 times.
✓ Branch 1 taken 58 times.
3141 for(int32_t i=0; i<temp_msg_count; i++)
3896 {
3897
1/2
✓ Branch 0 taken 3083 times.
✗ Branch 1 not taken.
3083 init_msgstr(&tempMsgString);
3898
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 3077 times.
3083 if(s_version > 8)
3899 {
3900
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if(!p_igetl(&string_length,f,true))
3901 {
3902 return qe_invalid;
3903 }
3904 6 }
3905
1/2
✓ Branch 0 taken 3083 times.
✗ Branch 1 not taken.
3083 if (string_length > 0)
3906 {
3907
2/4
✓ Branch 0 taken 3083 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3083 times.
✗ Branch 3 not taken.
3083 if (!pfread(buf, string_length, f, true))
3908 {
3909 return qe_invalid;
3910 }
3911 3083 }
3912 else
3913 {
3914 buf[0] = 0;
3915 }
3916
3917
2/4
✓ Branch 0 taken 3083 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3083 times.
✗ Branch 3 not taken.
3083 if(!p_igetw(&tempMsgString.nextstring,f,true))
3918 {
3919 return qe_invalid;
3920 }
3921
3922
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3083 times.
3083 if(s_version<2)
3923 {
3924 buf[72] = '\0';
3925 tempMsgString.s = buf;
3926 }
3927 else
3928 {
3929 // June 2008: A bug corrupted the last 4 chars of a string.
3930 // Discard these.
3931
1/2
✓ Branch 0 taken 3083 times.
✗ Branch 1 not taken.
3083 if(s_version<3)
3932 {
3933 for(int32_t j=140; j<144; j++)
3934 {
3935 buf[j] = '\0';
3936 }
3937 }
3938
1/2
✓ Branch 0 taken 3083 times.
✗ Branch 1 not taken.
3083 if(string_length > 8192) string_length = 8192;
3939 3083 buf[string_length]='\0'; //Force-terminate
3940
1/2
✓ Branch 0 taken 3083 times.
✗ Branch 1 not taken.
3083 tempMsgString.s = buf;
3941
3942
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 3077 times.
3083 if ( s_version >= 6 )
3943 {
3944
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if(!p_igetl(&tempMsgString.tile,f,true))
3945 {
3946 return qe_invalid;
3947 }
3948 6 }
3949 else
3950 {
3951
2/4
✓ Branch 0 taken 3077 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3077 times.
✗ Branch 3 not taken.
3077 if(!p_igetw(&tempMsgString.tile,f,true))
3952 {
3953 return qe_invalid;
3954 }
3955 }
3956
3957
2/4
✓ Branch 0 taken 3083 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3083 times.
✗ Branch 3 not taken.
3083 if(!p_getc(&tempMsgString.cset,f,true))
3958 {
3959 return qe_invalid;
3960 }
3961
3962 byte dummy_char;
3963
3964
2/4
✓ Branch 0 taken 3083 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3083 times.
✗ Branch 3 not taken.
3083 if(!p_getc(&dummy_char,f,true)) // trans is stored as a char...
3965 {
3966 return qe_invalid;
3967 }
3968
3969 3083 tempMsgString.trans=dummy_char!=0;
3970
3971
2/4
✓ Branch 0 taken 3083 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3083 times.
✗ Branch 3 not taken.
3083 if(!p_getc(&tempMsgString.font,f,true))
3972 {
3973 return qe_invalid;
3974 }
3975
3976
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3083 times.
3083 if(s_version < 5)
3977 {
3978 if(!p_getc(&tempMsgString.y,f,true))
3979 {
3980 return qe_invalid;
3981 }
3982 }
3983 else
3984 {
3985
2/4
✓ Branch 0 taken 3083 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3083 times.
✗ Branch 3 not taken.
3083 if(!p_igetw(&tempMsgString.x,f,true))
3986 {
3987 return qe_invalid;
3988 }
3989
3990
2/4
✓ Branch 0 taken 3083 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3083 times.
✗ Branch 3 not taken.
3083 if(!p_igetw(&tempMsgString.y,f,true))
3991 {
3992 return qe_invalid;
3993 }
3994
3995
2/4
✓ Branch 0 taken 3083 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3083 times.
✗ Branch 3 not taken.
3083 if(!p_igetw(&tempMsgString.w,f,true))
3996 {
3997 return qe_invalid;
3998 }
3999
4000
2/4
✓ Branch 0 taken 3083 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3083 times.
✗ Branch 3 not taken.
3083 if(!p_igetw(&tempMsgString.h,f,true))
4001 {
4002 return qe_invalid;
4003 }
4004
4005
2/4
✓ Branch 0 taken 3083 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3083 times.
✗ Branch 3 not taken.
3083 if(!p_getc(&tempMsgString.hspace,f,true))
4006 {
4007 return qe_invalid;
4008 }
4009
4010
2/4
✓ Branch 0 taken 3083 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3083 times.
✗ Branch 3 not taken.
3083 if(!p_getc(&tempMsgString.vspace,f,true))
4011 {
4012 return qe_invalid;
4013 }
4014
4015
2/4
✓ Branch 0 taken 3083 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3083 times.
✗ Branch 3 not taken.
3083 if(!p_getc(&tempMsgString.stringflags,f,true))
4016 {
4017 return qe_invalid;
4018 }
4019 }
4020
4021
2/2
✓ Branch 0 taken 3077 times.
✓ Branch 1 taken 6 times.
3083 if(s_version >= 7)
4022 {
4023
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 24 times.
30 for(int32_t q = 0; q < 4; ++q)
4024 {
4025
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_getc(&tempMsgString.margins[q],f,true))
4026 {
4027 return qe_invalid;
4028 }
4029 24 }
4030
4031
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if(!p_igetl(&tempMsgString.portrait_tile,f,true))
4032 {
4033 return qe_invalid;
4034 }
4035
4036
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if(!p_getc(&tempMsgString.portrait_cset,f,true))
4037 {
4038 return qe_invalid;
4039 }
4040
4041
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if(!p_getc(&tempMsgString.portrait_x,f,true))
4042 {
4043 return qe_invalid;
4044 }
4045
4046
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if(!p_getc(&tempMsgString.portrait_y,f,true))
4047 {
4048 return qe_invalid;
4049 }
4050
4051
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if(!p_getc(&tempMsgString.portrait_tw,f,true))
4052 {
4053 return qe_invalid;
4054 }
4055
4056
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if(!p_getc(&tempMsgString.portrait_th,f,true))
4057 {
4058 return qe_invalid;
4059 }
4060 6 }
4061
4062
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 3077 times.
3083 if(s_version >= 8)
4063 {
4064
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if(!p_getc(&tempMsgString.shadow_type,f,true))
4065 {
4066 return qe_invalid;
4067 }
4068
4069
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if(!p_getc(&tempMsgString.shadow_color,f,true))
4070 {
4071 return qe_invalid;
4072 }
4073 6 }
4074
4075
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 3077 times.
3083 if(s_version >= 10)
4076 {
4077
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if(!p_getc(&tempMsgString.drawlayer,f,true))
4078 {
4079 return qe_invalid;
4080 }
4081 6 }
4082
4083
2/4
✓ Branch 0 taken 3083 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3083 times.
✗ Branch 3 not taken.
3083 if(!p_getc(&tempMsgString.sfx,f,true))
4084 {
4085 return qe_invalid;
4086 }
4087
4088
1/2
✓ Branch 0 taken 3083 times.
✗ Branch 1 not taken.
3083 if(s_version>3)
4089 {
4090
2/4
✓ Branch 0 taken 3083 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3083 times.
✗ Branch 3 not taken.
3083 if(!p_igetw(&tempMsgString.listpos,f,true))
4091 {
4092 return qe_invalid;
4093 }
4094 3083 }
4095 }
4096
4097
1/2
✓ Branch 0 taken 3083 times.
✗ Branch 1 not taken.
3083 if(keepdata==true)
4098 {
4099
1/2
✓ Branch 0 taken 3083 times.
✗ Branch 1 not taken.
3083 MsgStrings[i].copyAll(tempMsgString);
4100 3083 }
4101 3083 }
4102 }
4103
4104
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 if(keepdata==true)
4105 {
4106 58 msg_count=temp_msg_count;
4107 58 }
4108
4109 58 return 0;
4110 58 }
4111
4112 58 int32_t readdoorcombosets(PACKFILE *f, zquestheader *Header, bool keepdata)
4113 {
4114
1/4
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
58 if((Header->zelda_version < 0x192)||
4115
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 ((Header->zelda_version == 0x192)&&(Header->build<158)))
4116 {
4117 return 0;
4118 }
4119
4120 58 word temp_door_combo_set_count=0;
4121 DoorComboSet tempDoorComboSet;
4122 word dummy_word;
4123 int32_t dummy_long;
4124 byte padding;
4125 58 int32_t s_version = 0;
4126
4127
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 if(keepdata==true)
4128 {
4129
2/2
✓ Branch 0 taken 14848 times.
✓ Branch 1 taken 58 times.
14906 for(int32_t i=0; i<MAXDOORCOMBOSETS; i++)
4130 {
4131 14848 memset(DoorComboSets+i, 0, sizeof(DoorComboSet));
4132 14848 }
4133 58 }
4134
4135
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 if(Header->zelda_version > 0x192)
4136 {
4137 //section version info
4138
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(!p_igetw(&s_version,f,true))
4139 {
4140 return qe_invalid;
4141 }
4142
4143 58 FFCore.quest_format[vDoors] = s_version;
4144
4145 //al_trace("Door combo sets version %d\n", dummy_word);
4146
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(!p_igetw(&dummy_word,f,true))
4147 {
4148 return qe_invalid;
4149 }
4150
4151 //section size
4152
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(!p_igetl(&dummy_long,f,true))
4153 {
4154 return qe_invalid;
4155 }
4156 58 }
4157
4158 //finally... section data
4159
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(!p_igetw(&temp_door_combo_set_count,f,true))
4160 {
4161 return qe_invalid;
4162 }
4163
4164
2/2
✓ Branch 0 taken 413 times.
✓ Branch 1 taken 58 times.
471 for(int32_t i=0; i<temp_door_combo_set_count; i++)
4165 {
4166 413 memset(&tempDoorComboSet, 0, sizeof(DoorComboSet));
4167
4168 //name
4169
1/2
✓ Branch 0 taken 413 times.
✗ Branch 1 not taken.
413 if(!pfread(&tempDoorComboSet.name,sizeof(tempDoorComboSet.name),f,true))
4170 {
4171 return qe_invalid;
4172 }
4173
4174
1/2
✓ Branch 0 taken 413 times.
✗ Branch 1 not taken.
413 if(Header->zelda_version < 0x193)
4175 {
4176 if(!p_getc(&padding,f,true))
4177 {
4178 return qe_invalid;
4179 }
4180 }
4181
4182 //up door
4183
2/2
✓ Branch 0 taken 3717 times.
✓ Branch 1 taken 413 times.
4130 for(int32_t j=0; j<9; j++)
4184 {
4185
2/2
✓ Branch 0 taken 14868 times.
✓ Branch 1 taken 3717 times.
18585 for(int32_t k=0; k<4; k++)
4186 {
4187
1/2
✓ Branch 0 taken 14868 times.
✗ Branch 1 not taken.
14868 if(!p_igetw(&tempDoorComboSet.doorcombo_u[j][k],f,true))
4188 {
4189 return qe_invalid;
4190 }
4191 14868 }
4192 3717 }
4193
4194
2/2
✓ Branch 0 taken 3717 times.
✓ Branch 1 taken 413 times.
4130 for(int32_t j=0; j<9; j++)
4195 {
4196
2/2
✓ Branch 0 taken 14868 times.
✓ Branch 1 taken 3717 times.
18585 for(int32_t k=0; k<4; k++)
4197 {
4198
1/2
✓ Branch 0 taken 14868 times.
✗ Branch 1 not taken.
14868 if(!p_getc(&tempDoorComboSet.doorcset_u[j][k],f,true))
4199 {
4200 return qe_invalid;
4201 }
4202 14868 }
4203 3717 }
4204
4205 //down door
4206
2/2
✓ Branch 0 taken 3717 times.
✓ Branch 1 taken 413 times.
4130 for(int32_t j=0; j<9; j++)
4207 {
4208
2/2
✓ Branch 0 taken 14868 times.
✓ Branch 1 taken 3717 times.
18585 for(int32_t k=0; k<4; k++)
4209 {
4210
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14868 times.
14868 if(!p_igetw(&tempDoorComboSet.doorcombo_d[j][k],f,true))
4211 {
4212 return qe_invalid;
4213 }
4214 14868 }
4215 3717 }
4216
4217
2/2
✓ Branch 0 taken 3717 times.
✓ Branch 1 taken 413 times.
4130 for(int32_t j=0; j<9; j++)
4218 {
4219
2/2
✓ Branch 0 taken 14868 times.
✓ Branch 1 taken 3717 times.
18585 for(int32_t k=0; k<4; k++)
4220 {
4221
1/2
✓ Branch 0 taken 14868 times.
✗ Branch 1 not taken.
14868 if(!p_getc(&tempDoorComboSet.doorcset_d[j][k],f,true))
4222 {
4223 return qe_invalid;
4224 }
4225 14868 }
4226 3717 }
4227
4228 //left door
4229
2/2
✓ Branch 0 taken 3717 times.
✓ Branch 1 taken 413 times.
4130 for(int32_t j=0; j<9; j++)
4230 {
4231
2/2
✓ Branch 0 taken 22302 times.
✓ Branch 1 taken 3717 times.
26019 for(int32_t k=0; k<6; k++)
4232 {
4233
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22302 times.
22302 if(!p_igetw(&tempDoorComboSet.doorcombo_l[j][k],f,true))
4234 {
4235 return qe_invalid;
4236 }
4237 22302 }
4238 3717 }
4239
4240
2/2
✓ Branch 0 taken 3717 times.
✓ Branch 1 taken 413 times.
4130 for(int32_t j=0; j<9; j++)
4241 {
4242
2/2
✓ Branch 0 taken 22302 times.
✓ Branch 1 taken 3717 times.
26019 for(int32_t k=0; k<6; k++)
4243 {
4244
1/2
✓ Branch 0 taken 22302 times.
✗ Branch 1 not taken.
22302 if(!p_getc(&tempDoorComboSet.doorcset_l[j][k],f,true))
4245 {
4246 return qe_invalid;
4247 }
4248 22302 }
4249 3717 }
4250
4251 //right door
4252
2/2
✓ Branch 0 taken 3717 times.
✓ Branch 1 taken 413 times.
4130 for(int32_t j=0; j<9; j++)
4253 {
4254
2/2
✓ Branch 0 taken 22302 times.
✓ Branch 1 taken 3717 times.
26019 for(int32_t k=0; k<6; k++)
4255 {
4256
1/2
✓ Branch 0 taken 22302 times.
✗ Branch 1 not taken.
22302 if(!p_igetw(&tempDoorComboSet.doorcombo_r[j][k],f,true))
4257 {
4258 return qe_invalid;
4259 }
4260 22302 }
4261 3717 }
4262
4263
2/2
✓ Branch 0 taken 3717 times.
✓ Branch 1 taken 413 times.
4130 for(int32_t j=0; j<9; j++)
4264 {
4265
2/2
✓ Branch 0 taken 22302 times.
✓ Branch 1 taken 3717 times.
26019 for(int32_t k=0; k<6; k++)
4266 {
4267
1/2
✓ Branch 0 taken 22302 times.
✗ Branch 1 not taken.
22302 if(!p_getc(&tempDoorComboSet.doorcset_r[j][k],f,true))
4268 {
4269 return qe_invalid;
4270 }
4271 22302 }
4272 3717 }
4273
4274 //up bomb rubble
4275
2/2
✓ Branch 0 taken 826 times.
✓ Branch 1 taken 413 times.
1239 for(int32_t j=0; j<2; j++)
4276 {
4277
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 826 times.
826 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_u[j],f,true))
4278 {
4279 return qe_invalid;
4280 }
4281 826 }
4282
4283
2/2
✓ Branch 0 taken 826 times.
✓ Branch 1 taken 413 times.
1239 for(int32_t j=0; j<2; j++)
4284 {
4285
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 826 times.
826 if(!p_getc(&tempDoorComboSet.bombdoorcset_u[j],f,true))
4286 {
4287 return qe_invalid;
4288 }
4289 826 }
4290
4291 //down bomb rubble
4292
2/2
✓ Branch 0 taken 826 times.
✓ Branch 1 taken 413 times.
1239 for(int32_t j=0; j<2; j++)
4293 {
4294
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 826 times.
826 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_d[j],f,true))
4295 {
4296 return qe_invalid;
4297 }
4298 826 }
4299
4300
2/2
✓ Branch 0 taken 826 times.
✓ Branch 1 taken 413 times.
1239 for(int32_t j=0; j<2; j++)
4301 {
4302
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 826 times.
826 if(!p_getc(&tempDoorComboSet.bombdoorcset_d[j],f,true))
4303 {
4304 return qe_invalid;
4305 }
4306 826 }
4307
4308 //left bomb rubble
4309
2/2
✓ Branch 0 taken 1239 times.
✓ Branch 1 taken 413 times.
1652 for(int32_t j=0; j<3; j++)
4310 {
4311
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1239 times.
1239 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_l[j],f,true))
4312 {
4313 return qe_invalid;
4314 }
4315 1239 }
4316
4317
2/2
✓ Branch 0 taken 1239 times.
✓ Branch 1 taken 413 times.
1652 for(int32_t j=0; j<3; j++)
4318 {
4319
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1239 times.
1239 if(!p_getc(&tempDoorComboSet.bombdoorcset_l[j],f,true))
4320 {
4321 return qe_invalid;
4322 }
4323 1239 }
4324
4325
1/2
✓ Branch 0 taken 413 times.
✗ Branch 1 not taken.
413 if(Header->zelda_version < 0x193)
4326 {
4327 if(!p_getc(&padding,f,true))
4328 {
4329 return qe_invalid;
4330 }
4331
4332 }
4333
4334 //right bomb rubble
4335
2/2
✓ Branch 0 taken 1239 times.
✓ Branch 1 taken 413 times.
1652 for(int32_t j=0; j<3; j++)
4336 {
4337
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1239 times.
1239 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_r[j],f,true))
4338 {
4339 return qe_invalid;
4340 }
4341 1239 }
4342
4343
2/2
✓ Branch 0 taken 1239 times.
✓ Branch 1 taken 413 times.
1652 for(int32_t j=0; j<3; j++)
4344 {
4345
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1239 times.
1239 if(!p_getc(&tempDoorComboSet.bombdoorcset_r[j],f,true))
4346 {
4347 return qe_invalid;
4348 }
4349 1239 }
4350
4351
1/2
✓ Branch 0 taken 413 times.
✗ Branch 1 not taken.
413 if(Header->zelda_version < 0x193)
4352 {
4353 if(!p_getc(&padding,f,true))
4354 {
4355 return qe_invalid;
4356 }
4357 }
4358
4359 //walkthrough stuff
4360
2/2
✓ Branch 0 taken 1652 times.
✓ Branch 1 taken 413 times.
2065 for(int32_t j=0; j<4; j++)
4361 {
4362
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1652 times.
1652 if(!p_igetw(&tempDoorComboSet.walkthroughcombo[j],f,true))
4363 {
4364 return qe_invalid;
4365 }
4366 1652 }
4367
4368
2/2
✓ Branch 0 taken 1652 times.
✓ Branch 1 taken 413 times.
2065 for(int32_t j=0; j<4; j++)
4369 {
4370
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1652 times.
1652 if(!p_getc(&tempDoorComboSet.walkthroughcset[j],f,true))
4371 {
4372 return qe_invalid;
4373 }
4374 1652 }
4375
4376 //flags
4377
2/2
✓ Branch 0 taken 826 times.
✓ Branch 1 taken 413 times.
1239 for(int32_t j=0; j<2; j++)
4378 {
4379
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 826 times.
826 if(!p_getc(&tempDoorComboSet.flags[j],f,true))
4380 {
4381 return qe_invalid;
4382 }
4383 826 }
4384
4385
1/2
✓ Branch 0 taken 413 times.
✗ Branch 1 not taken.
413 if(Header->zelda_version < 0x193)
4386 {
4387 if(!pfread(&tempDoorComboSet.expansion,sizeof(tempDoorComboSet.expansion),f,true))
4388 {
4389 return qe_invalid;
4390 }
4391 }
4392
4393
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 413 times.
413 if(keepdata==true)
4394 {
4395 413 memcpy(&DoorComboSets[i], &tempDoorComboSet, sizeof(tempDoorComboSet));
4396 413 }
4397 413 }
4398
4399
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 if(keepdata==true)
4400 {
4401 58 door_combo_set_count=temp_door_combo_set_count;
4402 58 }
4403
4404 58 return 0;
4405 58 }
4406
4407 int32_t count_dmaps()
4408 {
4409 int32_t i=MAXDMAPS-1;
4410 bool found=false;
4411
4412 while(i>=0 && !found)
4413 {
4414 if((DMaps[i].map!=0)||(DMaps[i].level!=0)||(DMaps[i].xoff!=0)||
4415 (DMaps[i].compass!=0)||(DMaps[i].color!=0)||(DMaps[i].midi!=0)||
4416 (DMaps[i].cont!=0)||(DMaps[i].type!=0))
4417 found=true;
4418
4419 for(int32_t j=0; j<8; j++)
4420 {
4421 if(DMaps[i].grid[j]!=0)
4422
4423 found=true;
4424 }
4425
4426 if((DMaps[i].name[0]!=0)||(DMaps[i].title[0]!=0)||
4427 (DMaps[i].intro[0]!=0)||(DMaps[i].tmusic[0]!=0))
4428 found=true;
4429
4430 if((DMaps[i].minimap_1_tile!=0)||(DMaps[i].minimap_2_tile!=0)||
4431 (DMaps[i].largemap_1_tile!=0)||(DMaps[i].largemap_2_tile!=0)||
4432 (DMaps[i].minimap_1_cset!=0)||(DMaps[i].minimap_2_cset!=0)||
4433 (DMaps[i].largemap_1_cset!=0)||(DMaps[i].largemap_2_cset!=0))
4434 found=true;
4435
4436 if(!found)
4437 {
4438 i--;
4439 }
4440 }
4441
4442 return i+1;
4443 }
4444
4445
4446 int32_t count_shops(miscQdata *Misc)
4447 {
4448 int32_t i=255,j;
4449 bool found=false;
4450
4451 while(i>=0 && !found)
4452 {
4453 j=2;
4454
4455 while(j>=0 && !found)
4456 {
4457 if((Misc->shop[i].hasitem[j]!=0)||(Misc->shop[i].price[j]!=0))
4458 {
4459 found=true;
4460 }
4461 else
4462 {
4463 j--;
4464 }
4465 }
4466
4467 if(Misc->shop[i].name[0]!=0)
4468 {
4469 found=true;
4470 }
4471
4472 if(!found)
4473 {
4474 i--;
4475 }
4476 }
4477
4478 return i+1;
4479 }
4480
4481 int32_t count_infos(miscQdata *Misc)
4482 {
4483 int32_t i=255,j;
4484 bool found=false;
4485
4486 while(i>=0 && !found)
4487 {
4488 j=2;
4489
4490 while(j>=0 && !found)
4491 {
4492 if((Misc->info[i].str[j]!=0)||(Misc->info[i].price[j]!=0))
4493 {
4494 found=true;
4495 }
4496 else
4497 {
4498 j--;
4499 }
4500 }
4501
4502 if(Misc->info[i].name[0]!=0)
4503 {
4504 found=true;
4505 }
4506
4507 if(!found)
4508 {
4509 i--;
4510 }
4511 }
4512
4513 return i+1;
4514 }
4515
4516 int32_t count_warprings(miscQdata *Misc)
4517 {
4518 int32_t i=15,j;
4519 bool found=false;
4520
4521 while(i>=0 && !found)
4522 {
4523 j=7;
4524
4525 while(j>=0 && !found)
4526 {
4527 if((Misc->warp[i].dmap[j]!=0)||(Misc->warp[i].scr[j]!=0))
4528 {
4529 found=true;
4530 }
4531 else
4532 {
4533 j--;
4534 }
4535 }
4536
4537 if(!found)
4538 {
4539 i--;
4540 }
4541 }
4542
4543 return i+1;
4544 }
4545
4546 int32_t count_palcycles(miscQdata *Misc)
4547 {
4548 int32_t i=255,j;
4549 bool found=false;
4550
4551 while(i>=0 && !found)
4552 {
4553 j=2;
4554
4555 while(j>=0 && !found)
4556 {
4557 if(Misc->cycles[i][j].count!=0)
4558 {
4559 found=true;
4560 }
4561 else
4562 {
4563 j--;
4564 }
4565 }
4566
4567 if(!found)
4568 {
4569 i--;
4570 }
4571 }
4572
4573 return i+1;
4574 }
4575
4576 98114 void clear_screen(mapscr *temp_scr)
4577 {
4578 98114 temp_scr->zero_memory();
4579 98114 }
4580
4581 58 int32_t readdmaps(PACKFILE *f, zquestheader *Header, word, word, word start_dmap, word max_dmaps, bool keepdata)
4582 {
4583 58 word dmapstoread=0;
4584 dmap tempDMap;
4585
4586 int32_t dummy;
4587 58 word s_version=0, s_cversion=0;
4588 byte padding;
4589
4590
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 if(keepdata==true)
4591 {
4592
2/2
✓ Branch 0 taken 29696 times.
✓ Branch 1 taken 58 times.
29754 for(int32_t i=0; i<max_dmaps; i++)
4593 {
4594 29696 memset(&DMaps[start_dmap+i],0,sizeof(dmap));
4595 29696 sprintf(DMaps[start_dmap+i].title," ");
4596 29696 sprintf(DMaps[start_dmap+i].intro," ");
4597 29696 DMaps[start_dmap+i].type |= dmCAVE;
4598 29696 }
4599 58 }
4600
4601
2/4
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 58 times.
✗ Branch 3 not taken.
58 if(!Header || Header->zelda_version > 0x192)
4602 {
4603 //section version info
4604
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(!p_igetw(&s_version,f,true))
4605 {
4606 return qe_invalid;
4607 }
4608
4609 58 FFCore.quest_format[vDMaps] = s_version;
4610
4611 //al_trace("DMaps version %d\n", s_version);
4612
4613
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(!p_igetw(&s_cversion,f,true))
4614 {
4615 return qe_invalid;
4616 }
4617
4618 //section size
4619
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(!p_igetl(&dummy,f,true))
4620 {
4621 return qe_invalid;
4622 }
4623
4624 //finally... section data
4625
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(!p_igetw(&dmapstoread,f,true))
4626 {
4627 return qe_invalid;
4628 }
4629 58 }
4630 else
4631 {
4632 if((Header->zelda_version < 0x192)||
4633 ((Header->zelda_version == 0x192)&&(Header->build<5)))
4634 {
4635 dmapstoread=32;
4636 }
4637 else if(s_version <= 4)
4638 {
4639 dmapstoread=OLDMAXDMAPS;
4640 }
4641 else
4642 {
4643 dmapstoread=MAXDMAPS;
4644 }
4645 }
4646
4647
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 dmapstoread=zc_min(dmapstoread, max_dmaps);
4648
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 dmapstoread=zc_min(dmapstoread, MAXDMAPS-start_dmap);
4649
4650
2/2
✓ Branch 0 taken 29696 times.
✓ Branch 1 taken 58 times.
29754 for(int32_t i=start_dmap; i<dmapstoread+start_dmap; i++)
4651 {
4652 29696 memset(&tempDMap,0,sizeof(dmap));
4653 29696 sprintf(tempDMap.title," ");
4654 29696 sprintf(tempDMap.intro," ");
4655
4656
1/2
✓ Branch 0 taken 29696 times.
✗ Branch 1 not taken.
29696 if(!p_getc(&tempDMap.map,f,keepdata))
4657 {
4658 return qe_invalid;
4659 }
4660
4661
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29696 times.
29696 if(s_version <= 4)
4662 {
4663 byte tempbyte;
4664
4665 if(!p_getc(&tempbyte,f,keepdata))
4666 {
4667 return qe_invalid;
4668 }
4669
4670 tempDMap.level=(word)tempbyte;
4671 }
4672 else
4673 {
4674
1/2
✓ Branch 0 taken 29696 times.
✗ Branch 1 not taken.
29696 if(!p_igetw(&tempDMap.level,f,keepdata))
4675 {
4676 return qe_invalid;
4677 }
4678 }
4679
4680
1/2
✓ Branch 0 taken 29696 times.
✗ Branch 1 not taken.
29696 if(!p_getc(&tempDMap.xoff,f,keepdata))
4681 {
4682 return qe_invalid;
4683 }
4684
4685
1/2
✓ Branch 0 taken 29696 times.
✗ Branch 1 not taken.
29696 if(!p_getc(&tempDMap.compass,f,keepdata))
4686 {
4687 return qe_invalid;
4688 }
4689
4690
1/2
✓ Branch 0 taken 29696 times.
✗ Branch 1 not taken.
29696 if(s_version > 8) // February 2009
4691 {
4692
1/2
✓ Branch 0 taken 29696 times.
✗ Branch 1 not taken.
29696 if(!p_igetw(&tempDMap.color,f,true))
4693 {
4694 return qe_invalid;
4695 }
4696 29696 }
4697 else
4698 {
4699 byte tempbyte;
4700
4701 if(!p_getc(&tempbyte,f,true))
4702 {
4703 return qe_invalid;
4704 }
4705
4706 tempDMap.color = (word)tempbyte;
4707 }
4708
4709
1/2
✓ Branch 0 taken 29696 times.
✗ Branch 1 not taken.
29696 if(!p_getc(&tempDMap.midi,f,keepdata))
4710 {
4711 return qe_invalid;
4712 }
4713
4714
1/2
✓ Branch 0 taken 29696 times.
✗ Branch 1 not taken.
29696 if(!p_getc(&tempDMap.cont,f,keepdata))
4715 {
4716 return qe_invalid;
4717 }
4718
4719
1/2
✓ Branch 0 taken 29696 times.
✗ Branch 1 not taken.
29696 if(!p_getc(&tempDMap.type,f,keepdata))
4720 {
4721 return qe_invalid;
4722 }
4723
4724
3/4
✓ Branch 0 taken 175 times.
✓ Branch 1 taken 29521 times.
✓ Branch 2 taken 175 times.
✗ Branch 3 not taken.
29871 if((tempDMap.type & dmfTYPE) == dmOVERW &&
4725
1/2
✓ Branch 0 taken 175 times.
✗ Branch 1 not taken.
175 (!Header || Header->zelda_version >= 0x210)) // Not sure exactly when this changed
4726 175 tempDMap.xoff = 0;
4727
4728
2/2
✓ Branch 0 taken 237568 times.
✓ Branch 1 taken 29696 times.
267264 for(int32_t j=0; j<8; j++)
4729 {
4730
1/2
✓ Branch 0 taken 237568 times.
✗ Branch 1 not taken.
237568 if(!p_getc(&tempDMap.grid[j],f,keepdata))
4731 {
4732 return qe_invalid;
4733 }
4734 237568 }
4735
4736
3/8
✓ Branch 0 taken 29696 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29696 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 29696 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
29696 if(Header && ((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<41))))
4737 {
4738 if(tempDMap.level>0&&tempDMap.level<10)
4739 {
4740 sprintf(tempDMap.title,"LEVEL-%d ", tempDMap.level);
4741 }
4742
4743 if(i==0 && Header->zelda_version <= 0x190)
4744 {
4745 tempDMap.cont-=tempDMap.xoff;
4746 tempDMap.compass-=tempDMap.xoff;
4747 }
4748
4749 //forgotten -DD
4750 if(tempDMap.level==0)
4751 {
4752 tempDMap.flags=dmfCAVES|dmf3STAIR|dmfWHIRLWIND|dmfGUYCAVES;
4753 }
4754 }
4755 else
4756 {
4757
1/2
✓ Branch 0 taken 29696 times.
✗ Branch 1 not taken.
29696 if(!pfread(&tempDMap.name,sizeof(DMaps[0].name),f,true))
4758 {
4759 return qe_invalid;
4760 }
4761
4762
1/2
✓ Branch 0 taken 29696 times.
✗ Branch 1 not taken.
29696 if(!pfread(&tempDMap.title,sizeof(DMaps[0].title),f,true))
4763 {
4764 return qe_invalid;
4765 }
4766
4767
1/2
✓ Branch 0 taken 29696 times.
✗ Branch 1 not taken.
29696 if(!pfread(&tempDMap.intro,sizeof(DMaps[0].intro),f,true))
4768 {
4769 return qe_invalid;
4770 }
4771
4772
3/8
✓ Branch 0 taken 29696 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29696 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 29696 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
29696 if(Header && ((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<152))))
4773 {
4774 if ((tempDMap.type & dmfTYPE) == dmOVERW) tempDMap.flags = dmfCAVES | dmf3STAIR | dmfWHIRLWIND | dmfGUYCAVES;
4775 if(keepdata==true)
4776 {
4777 memcpy(&DMaps[i], &tempDMap, sizeof(tempDMap));
4778 }
4779
4780 continue;
4781 }
4782
4783
2/4
✓ Branch 0 taken 29696 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29696 times.
✗ Branch 3 not taken.
29696 if(Header && (Header->zelda_version < 0x193))
4784 {
4785 if(!p_getc(&padding,f,keepdata))
4786 {
4787 return qe_invalid;
4788 }
4789 }
4790
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 28160 times.
29696 if ( s_version >= 11 )
4791 {
4792
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(!p_igetl(&tempDMap.minimap_1_tile,f,keepdata))
4793 {
4794 return qe_invalid;
4795 }
4796 1536 }
4797 else
4798 {
4799
1/2
✓ Branch 0 taken 28160 times.
✗ Branch 1 not taken.
28160 if(!p_igetw(&tempDMap.minimap_1_tile,f,keepdata))
4800 {
4801 return qe_invalid;
4802 }
4803 }
4804
4805
1/2
✓ Branch 0 taken 29696 times.
✗ Branch 1 not taken.
29696 if(!p_getc(&tempDMap.minimap_1_cset,f,keepdata))
4806 {
4807 return qe_invalid;
4808 }
4809
4810
2/4
✓ Branch 0 taken 29696 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29696 times.
✗ Branch 3 not taken.
29696 if(Header && (Header->zelda_version < 0x193))
4811 {
4812 if(!p_getc(&padding,f,keepdata))
4813 {
4814 return qe_invalid;
4815 }
4816 }
4817
4818
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 28160 times.
29696 if ( s_version >= 11 )
4819 {
4820
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(!p_igetl(&tempDMap.minimap_2_tile,f,keepdata))
4821 {
4822 return qe_invalid;
4823 }
4824 1536 }
4825 else
4826 {
4827
1/2
✓ Branch 0 taken 28160 times.
✗ Branch 1 not taken.
28160 if(!p_igetw(&tempDMap.minimap_2_tile,f,keepdata))
4828 {
4829 return qe_invalid;
4830 }
4831 }
4832
1/2
✓ Branch 0 taken 29696 times.
✗ Branch 1 not taken.
29696 if(!p_getc(&tempDMap.minimap_2_cset,f,keepdata))
4833 {
4834 return qe_invalid;
4835 }
4836
4837
2/4
✓ Branch 0 taken 29696 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29696 times.
✗ Branch 3 not taken.
29696 if(Header && (Header->zelda_version < 0x193))
4838 {
4839 if(!p_getc(&padding,f,keepdata))
4840 {
4841 return qe_invalid;
4842 }
4843 }
4844
4845
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 28160 times.
29696 if ( s_version >= 11 )
4846 {
4847
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(!p_igetl(&tempDMap.largemap_1_tile,f,keepdata))
4848 {
4849 return qe_invalid;
4850 }
4851 1536 }
4852 else
4853 {
4854
1/2
✓ Branch 0 taken 28160 times.
✗ Branch 1 not taken.
28160 if(!p_igetw(&tempDMap.largemap_1_tile,f,keepdata))
4855 {
4856 return qe_invalid;
4857 }
4858 }
4859
4860
1/2
✓ Branch 0 taken 29696 times.
✗ Branch 1 not taken.
29696 if(!p_getc(&tempDMap.largemap_1_cset,f,keepdata))
4861 {
4862 return qe_invalid;
4863 }
4864
4865
2/4
✓ Branch 0 taken 29696 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29696 times.
✗ Branch 3 not taken.
29696 if(Header && (Header->zelda_version < 0x193))
4866 {
4867
4868 if(!p_getc(&padding,f,keepdata))
4869 {
4870 return qe_invalid;
4871 }
4872 }
4873
4874
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 28160 times.
29696 if ( s_version >= 11 )
4875 {
4876
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(!p_igetl(&tempDMap.largemap_2_tile,f,keepdata))
4877 {
4878 return qe_invalid;
4879 }
4880 1536 }
4881 else
4882 {
4883
1/2
✓ Branch 0 taken 28160 times.
✗ Branch 1 not taken.
28160 if(!p_igetw(&tempDMap.largemap_2_tile,f,keepdata))
4884 {
4885 return qe_invalid;
4886 }
4887 }
4888
1/2
✓ Branch 0 taken 29696 times.
✗ Branch 1 not taken.
29696 if(!p_getc(&tempDMap.largemap_2_cset,f,keepdata))
4889 {
4890 return qe_invalid;
4891 }
4892
4893
1/2
✓ Branch 0 taken 29696 times.
✗ Branch 1 not taken.
29696 if(!pfread(&tempDMap.tmusic,sizeof(DMaps[0].tmusic),f,true))
4894 {
4895 return qe_invalid;
4896 }
4897 }
4898
4899
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29696 times.
29696 if(s_version>1)
4900 {
4901
1/2
✓ Branch 0 taken 29696 times.
✗ Branch 1 not taken.
29696 if(!p_getc(&tempDMap.tmusictrack,f,keepdata))
4902 {
4903 return qe_invalid;
4904 }
4905
4906
1/2
✓ Branch 0 taken 29696 times.
✗ Branch 1 not taken.
29696 if(!p_getc(&tempDMap.active_subscreen,f,keepdata))
4907 {
4908 return qe_invalid;
4909 }
4910
4911
1/2
✓ Branch 0 taken 29696 times.
✗ Branch 1 not taken.
29696 if(!p_getc(&tempDMap.passive_subscreen,f,keepdata))
4912 {
4913 return qe_invalid;
4914 }
4915 29696 }
4916
4917
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29696 times.
29696 if(s_version>2)
4918 {
4919 byte di[32];
4920
4921
1/2
✓ Branch 0 taken 29696 times.
✗ Branch 1 not taken.
29696 if(!pfread(&di, 32, f, true)) return qe_invalid;
4922
4923
2/2
✓ Branch 0 taken 7602176 times.
✓ Branch 1 taken 29696 times.
7631872 for(int32_t j=0; j<MAXITEMS; j++)
4924 {
4925
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7602176 times.
7602176 if(di[j/8] & (1 << (j%8))) tempDMap.disableditems[j]=1;
4926 7602176 else tempDMap.disableditems[j]=0;
4927 7602176 }
4928 29696 }
4929
4930
1/2
✓ Branch 0 taken 29696 times.
✗ Branch 1 not taken.
29696 if(s_version >= 6)
4931 {
4932
1/2
✓ Branch 0 taken 29696 times.
✗ Branch 1 not taken.
29696 if(!p_igetl(&tempDMap.flags,f,keepdata))
4933 {
4934 return qe_invalid;
4935 }
4936 29696 }
4937 else if(s_version>3)
4938 {
4939 char temp;
4940
4941 if(!p_getc(&temp,f,keepdata))
4942 {
4943 return qe_invalid;
4944 }
4945
4946 tempDMap.flags = temp;
4947 }
4948 else if(tempDMap.level==0 && ((Header->zelda_version < 0x211) || ((Header->zelda_version == 0x211) && (Header->build<18))))
4949 {
4950 tempDMap.flags=dmfCAVES|dmf3STAIR|dmfWHIRLWIND|dmfGUYCAVES;
4951 }
4952 else
4953 tempDMap.flags=0;
4954
4955
1/2
✓ Branch 0 taken 29696 times.
✗ Branch 1 not taken.
29696 if(s_version<7)
4956 {
4957 if(tempDMap.level==0 && get_bit(deprecated_rules,14))
4958 tempDMap.flags|= dmfVIEWMAP;
4959 }
4960
4961
1/2
✓ Branch 0 taken 29696 times.
✗ Branch 1 not taken.
29696 if(s_version<8)
4962 {
4963 if(tempDMap.level==0 && (tempDMap.type&dmfTYPE)==dmDNGN)
4964 {
4965 tempDMap.type &= ~dmDNGN;
4966 tempDMap.type |= dmCAVE;
4967 }
4968 else if((tempDMap.type&dmfTYPE)==dmCAVE)
4969 {
4970 tempDMap.flags |= dmfMINIMAPCOLORFIX;
4971 }
4972 }
4973
4974
3/8
✓ Branch 0 taken 29696 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 29696 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 29696 times.
✗ Branch 7 not taken.
29696 if(Header && ((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>=41)))
4975 29696 && (Header->zelda_version < 0x193))
4976 {
4977 if(!p_getc(&padding,f,keepdata))
4978 {
4979 return qe_invalid;
4980 }
4981 }
4982
4983
2/2
✓ Branch 0 taken 28160 times.
✓ Branch 1 taken 1536 times.
29696 if(s_version >= 10)
4984 {
4985
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(!p_getc(&tempDMap.sideview,f,keepdata))
4986 {
4987 return qe_invalid;
4988 }
4989 1536 }
4990
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 28160 times.
29696 if(s_version < 10) tempDMap.sideview = 0;
4991
4992 //Dmap Scripts
4993
2/2
✓ Branch 0 taken 28160 times.
✓ Branch 1 taken 1536 times.
29696 if(s_version >= 12)
4994 {
4995
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(!p_igetw(&tempDMap.script,f,keepdata))
4996 {
4997 return qe_invalid;
4998 }
4999
2/2
✓ Branch 0 taken 12288 times.
✓ Branch 1 taken 1536 times.
13824 for ( int32_t q = 0; q < 8; q++ )
5000 {
5001
1/2
✓ Branch 0 taken 12288 times.
✗ Branch 1 not taken.
12288 if(!p_igetl(&tempDMap.initD[q],f,keepdata))
5002 {
5003 return qe_invalid;
5004 }
5005 12288 }
5006 1536 }
5007
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 28160 times.
29696 if ( s_version < 12 )
5008 {
5009 28160 tempDMap.script = 0;
5010
2/2
✓ Branch 0 taken 225280 times.
✓ Branch 1 taken 28160 times.
253440 for ( int32_t q = 0; q < 8; q++ )
5011 {
5012 225280 tempDMap.initD[q] = 0;
5013 225280 }
5014 28160 }
5015
5016
2/2
✓ Branch 0 taken 28160 times.
✓ Branch 1 taken 1536 times.
29696 if(s_version >= 13)
5017 {
5018
2/2
✓ Branch 0 taken 12288 times.
✓ Branch 1 taken 1536 times.
13824 for ( int32_t q = 0; q < 8; q++ )
5019 {
5020
2/2
✓ Branch 0 taken 798720 times.
✓ Branch 1 taken 12288 times.
811008 for ( int32_t w = 0; w < 65; w++ )
5021 {
5022
1/2
✓ Branch 0 taken 798720 times.
✗ Branch 1 not taken.
798720 if(!p_getc(&tempDMap.initD_label[q][w],f,keepdata))
5023 {
5024 return qe_invalid;
5025 }
5026 798720 }
5027 12288 }
5028 1536 }
5029
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 28160 times.
29696 if ( s_version < 13 )
5030 {
5031 28160 tempDMap.script = 0;
5032
2/2
✓ Branch 0 taken 225280 times.
✓ Branch 1 taken 28160 times.
253440 for ( int32_t q = 0; q < 8; q++ )
5033 {
5034
2/2
✓ Branch 0 taken 14643200 times.
✓ Branch 1 taken 225280 times.
14868480 for ( int32_t w = 0; w < 65; w++ )
5035 14643200 tempDMap.initD_label[q][w] = 0;
5036 225280 }
5037 28160 }
5038
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 28160 times.
29696 if(s_version >= 14)
5039 {
5040
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(!p_igetw(&tempDMap.active_sub_script,f,keepdata))
5041 {
5042 return qe_invalid;
5043 }
5044
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(!p_igetw(&tempDMap.passive_sub_script,f,keepdata))
5045 {
5046 return qe_invalid;
5047 }
5048
2/2
✓ Branch 0 taken 12288 times.
✓ Branch 1 taken 1536 times.
13824 for ( int32_t q = 0; q < 8; ++q )
5049 {
5050
1/2
✓ Branch 0 taken 12288 times.
✗ Branch 1 not taken.
12288 if(!p_igetl(&tempDMap.sub_initD[q],f,keepdata))
5051 {
5052 return qe_invalid;
5053 }
5054 12288 }
5055
2/2
✓ Branch 0 taken 12288 times.
✓ Branch 1 taken 1536 times.
13824 for(int32_t q = 0; q < 8; ++q)
5056 {
5057
2/2
✓ Branch 0 taken 798720 times.
✓ Branch 1 taken 12288 times.
811008 for ( int32_t w = 0; w < 65; ++w )
5058 {
5059
1/2
✓ Branch 0 taken 798720 times.
✗ Branch 1 not taken.
798720 if(!p_getc(&tempDMap.sub_initD_label[q][w],f,keepdata))
5060 {
5061 return qe_invalid;
5062 }
5063 798720 }
5064 12288 }
5065 1536 }
5066 else
5067 {
5068 28160 tempDMap.active_sub_script = 0;
5069 28160 tempDMap.passive_sub_script = 0;
5070
2/2
✓ Branch 0 taken 225280 times.
✓ Branch 1 taken 28160 times.
253440 for(int32_t q = 0; q < 8; ++q)
5071 {
5072 225280 tempDMap.sub_initD[q] = 0;
5073
2/2
✓ Branch 0 taken 14643200 times.
✓ Branch 1 taken 225280 times.
14868480 for(int32_t w = 0; w < 65; ++w)
5074 14643200 tempDMap.sub_initD_label[q][w] = 0;
5075 225280 }
5076 }
5077
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 28160 times.
29696 if(s_version >= 15)
5078 {
5079
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(!p_igetw(&tempDMap.onmap_script,f,keepdata))
5080 {
5081 return qe_invalid;
5082 }
5083
2/2
✓ Branch 0 taken 12288 times.
✓ Branch 1 taken 1536 times.
13824 for ( int32_t q = 0; q < 8; ++q )
5084 {
5085
1/2
✓ Branch 0 taken 12288 times.
✗ Branch 1 not taken.
12288 if(!p_igetl(&tempDMap.onmap_initD[q],f,keepdata))
5086 {
5087 return qe_invalid;
5088 }
5089 12288 }
5090
2/2
✓ Branch 0 taken 12288 times.
✓ Branch 1 taken 1536 times.
13824 for(int32_t q = 0; q < 8; ++q)
5091 {
5092
2/2
✓ Branch 0 taken 798720 times.
✓ Branch 1 taken 12288 times.
811008 for ( int32_t w = 0; w < 65; ++w )
5093 {
5094
1/2
✓ Branch 0 taken 798720 times.
✗ Branch 1 not taken.
798720 if(!p_getc(&tempDMap.onmap_initD_label[q][w],f,keepdata))
5095 {
5096 return qe_invalid;
5097 }
5098 798720 }
5099 12288 }
5100 1536 }
5101 else
5102 {
5103 28160 tempDMap.onmap_script = 0;
5104
2/2
✓ Branch 0 taken 225280 times.
✓ Branch 1 taken 28160 times.
253440 for(int32_t q = 0; q < 8; ++q)
5105 {
5106 225280 tempDMap.onmap_initD[q] = 0;
5107
2/2
✓ Branch 0 taken 14643200 times.
✓ Branch 1 taken 225280 times.
14868480 for(int32_t w = 0; w < 65; ++w)
5108 {
5109 14643200 tempDMap.onmap_initD_label[q][w] = 0;
5110 14643200 }
5111 225280 }
5112 }
5113
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 28160 times.
29696 if(s_version >= 16)
5114 {
5115
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1536 times.
1536 if(!p_igetw(&tempDMap.mirrorDMap,f,keepdata))
5116 {
5117 return qe_invalid;
5118 }
5119 1536 }
5120 else
5121 {
5122 28160 tempDMap.mirrorDMap = -1;
5123 }
5124
5125
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29696 times.
29696 if(keepdata==true)
5126 {
5127 29696 memcpy(&DMaps[i], &tempDMap, sizeof(tempDMap));
5128 29696 }
5129 29696 }
5130
5131 58 return 0;
5132 58 }
5133
5134 58 int32_t readmisccolors(PACKFILE *f, zquestheader *Header, miscQdata *Misc, bool keepdata)
5135 {
5136 //these are here to bypass compiler warnings about unused arguments
5137 58 Header=Header;
5138
5139 miscQdata temp_misc;
5140 58 word s_version=0, s_cversion=0;
5141 58 int32_t tempsize=0;
5142 word dummyw;
5143
5144 58 memcpy(&temp_misc,Misc,sizeof(temp_misc));
5145
5146 //section version info
5147
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 if(!p_igetw(&s_version,f,true))
5148 {
5149 return qe_invalid;
5150 }
5151
5152 58 FFCore.quest_format[vColours] = s_version;
5153
5154 58 al_trace("Misc Colours section version: %d\n", s_version);
5155
5156 //al_trace("Misc. colors version %d\n", s_version);
5157
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(!p_igetw(&s_cversion,f,true))
5158 {
5159 return qe_invalid;
5160 }
5161
5162
5163 //section size
5164
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(!p_igetl(&tempsize,f,true))
5165 {
5166 return qe_invalid;
5167 }
5168
5169 //finally... section data
5170 58 readsize=0;
5171
5172
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(!p_getc(&temp_misc.colors.text,f,true))
5173 {
5174 return qe_invalid;
5175 }
5176
5177
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(!p_getc(&temp_misc.colors.caption,f,true))
5178 {
5179 return qe_invalid;
5180 }
5181
5182
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(!p_getc(&temp_misc.colors.overw_bg,f,true))
5183 {
5184 return qe_invalid;
5185 }
5186
5187
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(!p_getc(&temp_misc.colors.dngn_bg,f,true))
5188 {
5189 return qe_invalid;
5190 }
5191
5192
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(!p_getc(&temp_misc.colors.dngn_fg,f,true))
5193 {
5194 return qe_invalid;
5195 }
5196
5197
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(!p_getc(&temp_misc.colors.cave_fg,f,true))
5198 {
5199 return qe_invalid;
5200 }
5201
5202
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(!p_getc(&temp_misc.colors.bs_dk,f,true))
5203 {
5204 return qe_invalid;
5205 }
5206
5207
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(!p_getc(&temp_misc.colors.bs_goal,f,true))
5208 {
5209 return qe_invalid;
5210 }
5211
5212
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(!p_getc(&temp_misc.colors.compass_lt,f,true))
5213 {
5214 return qe_invalid;
5215 }
5216
5217
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(!p_getc(&temp_misc.colors.compass_dk,f,true))
5218 {
5219 return qe_invalid;
5220 }
5221
5222
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(!p_getc(&temp_misc.colors.subscr_bg,f,true))
5223 {
5224 return qe_invalid;
5225 }
5226
5227
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(!p_getc(&temp_misc.colors.triframe_color,f,true))
5228 {
5229 return qe_invalid;
5230 }
5231
5232
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(!p_getc(&temp_misc.colors.hero_dot,f,true))
5233 {
5234 return qe_invalid;
5235 }
5236
5237
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(!p_getc(&temp_misc.colors.bmap_bg,f,true))
5238 {
5239 return qe_invalid;
5240 }
5241
5242
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(!p_getc(&temp_misc.colors.bmap_fg,f,true))
5243 {
5244 return qe_invalid;
5245 }
5246
5247
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(!p_getc(&temp_misc.colors.triforce_cset,f,true))
5248 {
5249 return qe_invalid;
5250 }
5251
5252
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(!p_getc(&temp_misc.colors.triframe_cset,f,true))
5253 {
5254 return qe_invalid;
5255 }
5256
5257
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(!p_getc(&temp_misc.colors.overworld_map_cset,f,true))
5258 {
5259 return qe_invalid;
5260 }
5261
5262
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(!p_getc(&temp_misc.colors.dungeon_map_cset,f,true))
5263 {
5264 return qe_invalid;
5265 }
5266
5267
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(!p_getc(&temp_misc.colors.blueframe_cset,f,true))
5268 {
5269 return qe_invalid;
5270 }
5271
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 55 times.
58 if(s_version < 4)
5272 {
5273
1/2
✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
55 if(!p_igetw(&dummyw,f,true))
5274 return qe_invalid;
5275 55 temp_misc.colors.triforce_tile = dummyw;
5276
5277
1/2
✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
55 if(!p_igetw(&dummyw,f,true))
5278 return qe_invalid;
5279 55 temp_misc.colors.triframe_tile = dummyw;
5280
5281
1/2
✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
55 if(!p_igetw(&dummyw,f,true))
5282 return qe_invalid;
5283 55 temp_misc.colors.overworld_map_tile = dummyw;
5284
5285
1/2
✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
55 if(!p_igetw(&dummyw,f,true))
5286 return qe_invalid;
5287 55 temp_misc.colors.dungeon_map_tile = dummyw;
5288
5289
1/2
✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
55 if(!p_igetw(&dummyw,f,true))
5290 return qe_invalid;
5291 55 temp_misc.colors.blueframe_tile = dummyw;
5292
5293
1/2
✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
55 if(!p_igetw(&dummyw,f,true))
5294 return qe_invalid;
5295 55 temp_misc.colors.HCpieces_tile = dummyw;
5296 55 }
5297
5298
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(!p_getc(&temp_misc.colors.HCpieces_cset,f,true))
5299 {
5300 return qe_invalid;
5301 }
5302
5303
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(!p_getc(&temp_misc.colors.subscr_shadow,f,true))
5304 {
5305 return qe_invalid;
5306 }
5307
5308
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 if(s_version < 2)
5309 {
5310 temp_misc.colors.msgtext = 0x01;
5311 }
5312 else
5313 {
5314
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(!p_getc(&temp_misc.colors.msgtext, f, true))
5315 {
5316 return qe_invalid;
5317 }
5318 }
5319
5320
2/2
✓ Branch 0 taken 55 times.
✓ Branch 1 taken 3 times.
58 if ( s_version >= 3 ) //expanded tile pages to 825
5321 {
5322
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_igetl(&temp_misc.colors.triforce_tile,f,true))
5323 {
5324 return qe_invalid;
5325 }
5326
5327
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_igetl(&temp_misc.colors.triframe_tile,f,true))
5328 {
5329 return qe_invalid;
5330 }
5331
5332
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_igetl(&temp_misc.colors.overworld_map_tile,f,true))
5333 {
5334 return qe_invalid;
5335 }
5336
5337
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_igetl(&temp_misc.colors.dungeon_map_tile,f,true))
5338 {
5339 return qe_invalid;
5340 }
5341
5342
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_igetl(&temp_misc.colors.blueframe_tile,f,true))
5343 {
5344 return qe_invalid;
5345 }
5346
5347
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(!p_igetl(&temp_misc.colors.HCpieces_tile,f,true))
5348 {
5349 return qe_invalid;
5350 }
5351 3 }
5352
5353
5354
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 if(keepdata==true)
5355 {
5356 58 memcpy(Misc, &temp_misc, sizeof(temp_misc));
5357 58 }
5358
5359 58 return 0;
5360 58 }
5361
5362 58 int32_t readgameicons(PACKFILE *f, zquestheader *, miscQdata *Misc, bool keepdata)
5363 {
5364 miscQdata temp_misc;
5365 58 word s_version=0, s_cversion=0;
5366 byte icons;
5367 58 int32_t tempsize=0;
5368
5369 58 memcpy(&temp_misc,Misc,sizeof(temp_misc));
5370
5371 //section version info
5372
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 if(!p_igetw(&s_version,f,true))
5373 {
5374 return qe_invalid;
5375 }
5376
5377 58 FFCore.quest_format[vIcons] = s_version;
5378
5379 //al_trace("Game icons version %d\n", s_version);
5380
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(!p_igetw(&s_cversion,f,true))
5381 {
5382 return qe_invalid;
5383 }
5384
5385
5386 //section size
5387
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(!p_igetl(&tempsize,f,true))
5388 {
5389 return qe_invalid;
5390 }
5391
5392 //finally... section data
5393 58 readsize=0;
5394
5395 58 icons=4;
5396
5397
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 55 times.
58 if ( s_version >= 10 )
5398 {
5399
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 3 times.
15 for(int32_t i=0; i<icons; i++)
5400 {
5401
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!p_igetl(&temp_misc.icons[i],f,true))
5402 {
5403 return qe_invalid;
5404 }
5405 12 }
5406 3 }
5407 else
5408 {
5409
2/2
✓ Branch 0 taken 220 times.
✓ Branch 1 taken 55 times.
275 for(int32_t i=0; i<icons; i++)
5410 {
5411
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 220 times.
220 if(!p_igetw(&temp_misc.icons[i],f,true))
5412 {
5413 return qe_invalid;
5414 }
5415 220 }
5416 }
5417
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 if(keepdata==true)
5418 {
5419 58 memcpy(Misc, &temp_misc, sizeof(temp_misc));
5420 58 }
5421
5422 58 return 0;
5423 58 }
5424
5425 58 int32_t readmisc(PACKFILE *f, zquestheader *Header, miscQdata *Misc, bool keepdata)
5426 {
5427 58 word maxinfos=256;
5428 58 word maxshops=256;
5429 58 word shops=16, infos=16, warprings=8, palcycles=256, windwarps=9, triforces=8, icons=4;
5430 58 word ponds=16, pondsize=72, expansionsize=98*2;
5431 byte tempbyte, padding;
5432 miscQdata temp_misc;
5433 58 word s_version=0, s_cversion=0;
5434 word swaptmp;
5435 58 int32_t tempsize=0;
5436
5437 58 memcpy(&temp_misc,Misc,sizeof(temp_misc));
5438
5439
2/2
✓ Branch 0 taken 14848 times.
✓ Branch 1 taken 58 times.
14906 for(int32_t i=0; i<maxshops; ++i)
5440 {
5441 14848 memset(&temp_misc.shop, 0, sizeof(shoptype)*256);
5442 14848 }
5443
5444
2/2
✓ Branch 0 taken 14848 times.
✓ Branch 1 taken 58 times.
14906 for(int32_t i=0; i<maxinfos; ++i)
5445 {
5446 14848 memset(&temp_misc.info, 0, sizeof(infotype)*256);
5447 14848 }
5448
5449
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 if(Header->zelda_version > 0x192)
5450 {
5451 //section version info
5452
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(!p_igetw(&s_version,f,true))
5453 {
5454 return qe_invalid;
5455 }
5456
5457 58 FFCore.quest_format[vMisc] = s_version;
5458
5459 //al_trace("Misc. data version %d\n", s_version);
5460
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(!p_igetw(&s_cversion,f,true))
5461 {
5462 return qe_invalid;
5463 }
5464
5465
5466 //section size
5467
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(!p_igetl(&tempsize,f,true))
5468 {
5469 return qe_invalid;
5470 }
5471 58 }
5472
5473 //finally... section data
5474 58 readsize=0;
5475
5476 //shops
5477
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 if(Header->zelda_version > 0x192)
5478 {
5479
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(!p_igetw(&shops,f,true))
5480 {
5481 return qe_invalid;
5482 }
5483 58 }
5484
5485
2/2
✓ Branch 0 taken 487 times.
✓ Branch 1 taken 58 times.
545 for(int32_t i=0; i<shops; i++)
5486 {
5487
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 487 times.
487 if(s_version > 6)
5488 {
5489
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 487 times.
487 if(!pfread(temp_misc.shop[i].name,sizeof(temp_misc.shop[i].name),f,true))
5490 {
5491 return qe_invalid;
5492 }
5493 487 }
5494
5495
2/2
✓ Branch 0 taken 1461 times.
✓ Branch 1 taken 487 times.
1948 for(int32_t j=0; j<3; j++)
5496 {
5497
1/2
✓ Branch 0 taken 1461 times.
✗ Branch 1 not taken.
1461 if(!p_getc(&temp_misc.shop[i].item[j],f,true))
5498 {
5499 return qe_invalid;
5500 }
5501
5502
1/2
✓ Branch 0 taken 1461 times.
✗ Branch 1 not taken.
1461 if(s_version < 4)
5503 {
5504 temp_misc.shop[i].hasitem[j] = (temp_misc.shop[i].item[j] == 0) ? 0 : 1;
5505 }
5506 1461 }
5507
5508
1/2
✓ Branch 0 taken 487 times.
✗ Branch 1 not taken.
487 if(Header->zelda_version < 0x193)
5509 {
5510 if(!p_getc(&tempbyte,f,true))
5511 {
5512 return qe_invalid;
5513 }
5514 }
5515
5516
2/2
✓ Branch 0 taken 1461 times.
✓ Branch 1 taken 487 times.
1948 for(int32_t j=0; j<3; j++)
5517 {
5518
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1461 times.
1461 if(!p_igetw(&temp_misc.shop[i].price[j],f,true))
5519 {
5520 return qe_invalid;
5521 }
5522 1461 }
5523
5524
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 487 times.
487 if(s_version > 3)
5525 {
5526
2/2
✓ Branch 0 taken 1461 times.
✓ Branch 1 taken 487 times.
1948 for(int32_t j=0; j<3; j++)
5527 {
5528
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1461 times.
1461 if(!p_getc(&temp_misc.shop[i].hasitem[j],f,true))
5529 return qe_invalid;
5530 1461 }
5531 487 }
5532
5533 /*
5534 if(s_version < 8)
5535 {
5536 for(int32_t j=0; j<3; j++)
5537 {
5538 (&temp_misc.shop[i].str[j])=0; //initialise.
5539 }
5540 }
5541 */
5542 487 }
5543
5544 //filter all the 0 items to the end (yeah, bubble sort; sue me)
5545
2/2
✓ Branch 0 taken 14848 times.
✓ Branch 1 taken 58 times.
14906 for(int32_t i=0; i<maxshops; ++i)
5546 {
5547
2/2
✓ Branch 0 taken 29696 times.
✓ Branch 1 taken 14848 times.
44544 for(int32_t j=0; j<3-1; j++)
5548 {
5549
2/2
✓ Branch 0 taken 44544 times.
✓ Branch 1 taken 29696 times.
74240 for(int32_t k=0; k<2-j; k++)
5550 {
5551
2/2
✓ Branch 0 taken 1272 times.
✓ Branch 1 taken 43272 times.
44544 if(temp_misc.shop[i].hasitem[k]==0)
5552 {
5553 43272 swaptmp = temp_misc.shop[i].item[k];
5554 43272 temp_misc.shop[i].item[k] = temp_misc.shop[i].item[k+1];
5555 43272 temp_misc.shop[i].item[k+1] = swaptmp;
5556 43272 swaptmp = temp_misc.shop[i].price[k];
5557 43272 temp_misc.shop[i].price[k] = temp_misc.shop[i].price[k+1];
5558 43272 temp_misc.shop[i].price[k+1] = swaptmp;
5559 43272 swaptmp = temp_misc.shop[i].hasitem[k];
5560 43272 temp_misc.shop[i].hasitem[k] = temp_misc.shop[i].hasitem[k+1];
5561 43272 temp_misc.shop[i].hasitem[k+1] = swaptmp;
5562 43272 }
5563 44544 }
5564 29696 }
5565 14848 }
5566
5567 //infos
5568
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 if(Header->zelda_version > 0x192)
5569 {
5570
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(!p_igetw(&infos,f,true))
5571 {
5572 return qe_invalid;
5573 }
5574 58 }
5575
5576
2/2
✓ Branch 0 taken 848 times.
✓ Branch 1 taken 58 times.
906 for(int32_t i=0; i<infos; i++)
5577 {
5578
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 848 times.
848 if(s_version > 6)
5579 {
5580
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 848 times.
848 if(!pfread(temp_misc.info[i].name,sizeof(temp_misc.info[i].name),f,true))
5581 {
5582 return qe_invalid;
5583 }
5584 848 }
5585
5586
2/2
✓ Branch 0 taken 2544 times.
✓ Branch 1 taken 848 times.
3392 for(int32_t j=0; j<3; j++)
5587 {
5588
1/4
✓ Branch 0 taken 2544 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2544 if((Header->zelda_version < 0x192)||
5589
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2544 times.
2544 ((Header->zelda_version == 0x192)&&(Header->build<146)))
5590 {
5591 if(!p_getc(&tempbyte,f,true))
5592 {
5593 return qe_invalid;
5594 }
5595
5596 temp_misc.info[i].str[j]=tempbyte;
5597 }
5598 else
5599 {
5600
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2544 times.
2544 if(!p_igetw(&temp_misc.info[i].str[j],f,true))
5601 {
5602 return qe_invalid;
5603 }
5604 }
5605 2544 }
5606
5607
1/2
✓ Branch 0 taken 848 times.
✗ Branch 1 not taken.
848 if(Header->zelda_version < 0x193)
5608 {
5609 if(!p_getc(&tempbyte,f,true))
5610 {
5611 return qe_invalid;
5612 }
5613 }
5614
5615
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 848 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
848 if((Header->zelda_version == 0x192)&&(Header->build>145))
5616 {
5617 if(!p_getc(&padding,f,true))
5618 {
5619 return qe_invalid;
5620 }
5621 }
5622
5623
2/2
✓ Branch 0 taken 2544 times.
✓ Branch 1 taken 848 times.
3392 for(int32_t j=0; j<3; j++)
5624 {
5625
1/2
✓ Branch 0 taken 2544 times.
✗ Branch 1 not taken.
2544 if(!p_igetw(&temp_misc.info[i].price[j],f,true))
5626 {
5627 return qe_invalid;
5628 }
5629 2544 }
5630 848 }
5631
5632 //filter all the 0 strings to the end (yeah, bubble sort; sue me)
5633
2/2
✓ Branch 0 taken 14848 times.
✓ Branch 1 taken 58 times.
14906 for(int32_t i=0; i<maxinfos; ++i)
5634 {
5635
2/2
✓ Branch 0 taken 29696 times.
✓ Branch 1 taken 14848 times.
44544 for(int32_t j=0; j<3-1; j++)
5636 {
5637
2/2
✓ Branch 0 taken 44544 times.
✓ Branch 1 taken 29696 times.
74240 for(int32_t k=0; k<2-j; k++)
5638 {
5639
2/2
✓ Branch 0 taken 1023 times.
✓ Branch 1 taken 43521 times.
44544 if(temp_misc.info[i].str[k]==0)
5640 {
5641 43521 swaptmp = temp_misc.info[i].str[k];
5642 43521 temp_misc.info[i].str[k] = temp_misc.info[i].str[k+1];
5643 43521 temp_misc.info[i].str[k+1] = swaptmp;
5644 43521 swaptmp = temp_misc.info[i].price[k];
5645 43521 temp_misc.info[i].price[k] = temp_misc.info[i].price[k+1];
5646 43521 temp_misc.info[i].price[k+1] = swaptmp;
5647 43521 }
5648 44544 }
5649 29696 }
5650 14848 }
5651
5652
5653 //warp rings
5654
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 if(s_version > 5)
5655 58 warprings++;
5656
5657
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 if(Header->zelda_version > 0x192)
5658 {
5659
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(!p_igetw(&warprings,f,true))
5660 {
5661 return qe_invalid;
5662 }
5663 58 }
5664
5665
2/2
✓ Branch 0 taken 550 times.
✓ Branch 1 taken 58 times.
608 for(int32_t i=0; i<warprings; i++)
5666 {
5667
2/2
✓ Branch 0 taken 4950 times.
✓ Branch 1 taken 550 times.
5500 for(int32_t j=0; j<8+((s_version > 5)?1:0); j++)
5668 {
5669
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4950 times.
4950 if(s_version <= 3)
5670 {
5671 if(!p_getc(&tempbyte,f,true))
5672 {
5673 return qe_invalid;
5674 }
5675
5676 temp_misc.warp[i].dmap[j]=(word)tempbyte;
5677 }
5678 else
5679 {
5680
1/2
✓ Branch 0 taken 4950 times.
✗ Branch 1 not taken.
4950 if(!p_igetw(&temp_misc.warp[i].dmap[j],f,true))
5681 {
5682 return qe_invalid;
5683 }
5684 }
5685 4950 }
5686
5687
2/2
✓ Branch 0 taken 4950 times.
✓ Branch 1 taken 550 times.
5500 for(int32_t j=0; j<8+((s_version > 5)?1:0); j++)
5688 {
5689
1/2
✓ Branch 0 taken 4950 times.
✗ Branch 1 not taken.
4950 if(!p_getc(&temp_misc.warp[i].scr[j],f,true))
5690 {
5691 return qe_invalid;
5692 }
5693 4950 }
5694
5695
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 550 times.
550 if(!p_getc(&temp_misc.warp[i].size,f,true))
5696 {
5697 return qe_invalid;
5698 }
5699
5700
1/2
✓ Branch 0 taken 550 times.
✗ Branch 1 not taken.
550 if(Header->zelda_version < 0x193)
5701 {
5702 if(!p_getc(&tempbyte,f,true))
5703 {
5704 return qe_invalid;
5705 }
5706 }
5707 550 }
5708
5709 //palette cycles
5710
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(Header->zelda_version < 0x193) //in 1.93+, palette cycling is saved with the palettes
5711 {
5712 for(int32_t i=0; i<256; i++)
5713 {
5714 for(int32_t j=0; j<3; j++)
5715 {
5716 temp_misc.cycles[i][j].first=0;
5717 temp_misc.cycles[i][j].count=0;
5718 temp_misc.cycles[i][j].speed=0;
5719 }
5720 }
5721
5722 if((Header->zelda_version < 0x192)||
5723 ((Header->zelda_version == 0x192)&&(Header->build<73)))
5724 {
5725 palcycles=16;
5726 }
5727
5728 for(int32_t i=0; i<palcycles; i++)
5729 {
5730 for(int32_t j=0; j<3; j++)
5731 {
5732 if(!p_getc(&temp_misc.cycles[i][j].first,f,true))
5733 {
5734 return qe_invalid;
5735 }
5736
5737 if(!p_getc(&temp_misc.cycles[i][j].count,f,true))
5738 {
5739 return qe_invalid;
5740 }
5741
5742 if(!p_getc(&temp_misc.cycles[i][j].speed,f,true))
5743 {
5744 return qe_invalid;
5745 }
5746 }
5747 }
5748 }
5749
5750 //Wind warps are now just another warp ring.
5751
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(s_version <= 5)
5752 {
5753 if(Header->zelda_version > 0x192)
5754 {
5755 if(!p_igetw(&windwarps,f,true))
5756 {
5757 return qe_invalid;
5758 }
5759 }
5760
5761 for(int32_t i=0; i<windwarps; i++)
5762 {
5763 if(s_version <= 3)
5764 {
5765 if(!p_getc(&tempbyte,f,true))
5766 {
5767 return qe_invalid;
5768 }
5769
5770 temp_misc.warp[8].dmap[i]=tempbyte;
5771 }
5772 else
5773 {
5774 if(!p_igetw(&temp_misc.warp[8].dmap[i],f,true))
5775 {
5776 return qe_invalid;
5777 }
5778 }
5779
5780 if(!p_getc(&temp_misc.warp[8].scr[i],f,true))
5781 {
5782 return qe_invalid;
5783 }
5784
5785 temp_misc.warp[8].size = 9;
5786
5787 if(s_version == 5)
5788 {
5789 if(!p_getc(&tempbyte,f,true))
5790 {
5791 return qe_invalid;
5792 }
5793 }
5794 }
5795 }
5796
5797
5798 //triforce pieces
5799
2/2
✓ Branch 0 taken 464 times.
✓ Branch 1 taken 58 times.
522 for(int32_t i=0; i<triforces; i++)
5800 {
5801
1/2
✓ Branch 0 taken 464 times.
✗ Branch 1 not taken.
464 if(!p_getc(&temp_misc.triforce[i],f,true))
5802 {
5803 return qe_invalid;
5804 }
5805 464 }
5806
5807 //misc color data
5808
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(s_version<3)
5809 {
5810 if(!p_getc(&temp_misc.colors.text,f,true))
5811 {
5812 return qe_invalid;
5813 }
5814
5815 if(!p_getc(&temp_misc.colors.caption,f,true))
5816 {
5817 return qe_invalid;
5818 }
5819
5820 if(!p_getc(&temp_misc.colors.overw_bg,f,true))
5821 {
5822 return qe_invalid;
5823 }
5824
5825 if(!p_getc(&temp_misc.colors.dngn_bg,f,true))
5826 {
5827 return qe_invalid;
5828 }
5829
5830 if(!p_getc(&temp_misc.colors.dngn_fg,f,true))
5831 {
5832 return qe_invalid;
5833 }
5834
5835 if(!p_getc(&temp_misc.colors.cave_fg,f,true))
5836 {
5837 return qe_invalid;
5838 }
5839
5840 if(!p_getc(&temp_misc.colors.bs_dk,f,true))
5841 {
5842 return qe_invalid;
5843 }
5844
5845 if(!p_getc(&temp_misc.colors.bs_goal,f,true))
5846 {
5847 return qe_invalid;
5848 }
5849
5850 if(!p_getc(&temp_misc.colors.compass_lt,f,true))
5851 {
5852 return qe_invalid;
5853 }
5854
5855 if(!p_getc(&temp_misc.colors.compass_dk,f,true))
5856 {
5857 return qe_invalid;
5858 }
5859
5860 if(!p_getc(&temp_misc.colors.subscr_bg,f,true))
5861 {
5862 return qe_invalid;
5863 }
5864
5865 if(!p_getc(&temp_misc.colors.triframe_color,f,true))
5866 {
5867 return qe_invalid;
5868 }
5869
5870 if(!p_getc(&temp_misc.colors.hero_dot,f,true))
5871 {
5872 return qe_invalid;
5873 }
5874
5875 if(!p_getc(&temp_misc.colors.bmap_bg,f,true))
5876 {
5877 return qe_invalid;
5878 }
5879
5880 if(!p_getc(&temp_misc.colors.bmap_fg,f,true))
5881 {
5882 return qe_invalid;
5883 }
5884
5885 if(!p_getc(&temp_misc.colors.triforce_cset,f,true))
5886 {
5887 return qe_invalid;
5888 }
5889
5890 if(!p_getc(&temp_misc.colors.triframe_cset,f,true))
5891 {
5892 return qe_invalid;
5893 }
5894
5895 if(!p_getc(&temp_misc.colors.overworld_map_cset,f,true))
5896 {
5897 return qe_invalid;
5898 }
5899
5900 if(!p_getc(&temp_misc.colors.dungeon_map_cset,f,true))
5901 {
5902 return qe_invalid;
5903 }
5904
5905 if(!p_getc(&temp_misc.colors.blueframe_cset,f,true))
5906 {
5907 return qe_invalid;
5908 }
5909
5910 if(!p_igetw(&temp_misc.colors.triforce_tile,f,true))
5911 {
5912 return qe_invalid;
5913 }
5914
5915 if(!p_igetw(&temp_misc.colors.triframe_tile,f,true))
5916 {
5917 return qe_invalid;
5918 }
5919
5920 if(!p_igetw(&temp_misc.colors.overworld_map_tile,f,true))
5921 {
5922 return qe_invalid;
5923 }
5924
5925 if(!p_igetw(&temp_misc.colors.dungeon_map_tile,f,true))
5926 {
5927 return qe_invalid;
5928 }
5929
5930 if(!p_igetw(&temp_misc.colors.blueframe_tile,f,true))
5931 {
5932 return qe_invalid;
5933 }
5934
5935 if(!p_igetw(&temp_misc.colors.HCpieces_tile,f,true))
5936 {
5937 return qe_invalid;
5938 }
5939
5940 if(!p_getc(&temp_misc.colors.HCpieces_cset,f,true))
5941 {
5942 return qe_invalid;
5943 }
5944
5945 temp_misc.colors.msgtext = 0x01;
5946
5947 if(Header->zelda_version < 0x193)
5948 {
5949 for(int32_t i=0; i<7; i++)
5950 {
5951 if(!p_getc(&tempbyte,f,true))
5952 {
5953 return qe_invalid;
5954 }
5955 }
5956 }
5957
5958 if((Header->zelda_version == 0x192)&&(Header->build>145))
5959 {
5960 for(int32_t i=0; i<256; i++)
5961 {
5962 if(!p_getc(&tempbyte,f,true))
5963 {
5964 return qe_invalid;
5965 }
5966 }
5967 }
5968
5969 if(s_version>1)
5970 {
5971 if(!p_getc(&temp_misc.colors.subscr_shadow,f,true))
5972 {
5973 return qe_invalid;
5974 }
5975 }
5976
5977 //save game icons
5978 if((Header->zelda_version < 0x192)||
5979 ((Header->zelda_version == 0x192)&&(Header->build<73)))
5980 {
5981 icons=3;
5982 }
5983
5984 for(int32_t i=0; i<icons; i++)
5985 {
5986 if(!p_igetw(&temp_misc.icons[i],f,true))
5987 {
5988 return qe_invalid;
5989 }
5990 }
5991 }
5992
5993
1/4
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
58 if((Header->zelda_version < 0x192)||
5994
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 ((Header->zelda_version == 0x192)&&(Header->build<30)))
5995 {
5996 if(keepdata==true)
5997 {
5998 memcpy(Misc, &temp_misc, sizeof(temp_misc));
5999 }
6000
6001 return 0;
6002 }
6003
6004 //pond information
6005
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(Header->zelda_version < 0x193)
6006 {
6007 if((Header->zelda_version == 0x192)&&(Header->build<146))
6008 {
6009 pondsize=25;
6010 }
6011
6012 for(int32_t i=0; i<ponds; i++)
6013 {
6014 for(int32_t j=0; j<pondsize; j++)
6015 {
6016 if(!p_getc(&tempbyte,f,true))
6017 {
6018 return qe_invalid;
6019
6020 }
6021 }
6022 }
6023 }
6024
6025 //end string
6026
1/4
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
58 if((Header->zelda_version < 0x192)||
6027
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 ((Header->zelda_version == 0x192)&&(Header->build<146)))
6028 {
6029 if(!p_getc(&tempbyte,f,true))
6030 {
6031 return qe_invalid;
6032 }
6033
6034 temp_misc.endstring=tempbyte;
6035
6036 if(!p_getc(&tempbyte,f,true))
6037 {
6038 return qe_invalid;
6039 }
6040 }
6041 else
6042 {
6043
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(!p_igetw(&temp_misc.endstring,f,true))
6044 {
6045 return qe_invalid;
6046 }
6047 }
6048
6049 //expansion
6050
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(Header->zelda_version < 0x193)
6051 {
6052 if((Header->zelda_version == 0x192)&&(Header->build<73))
6053 {
6054 expansionsize=99*2;
6055 }
6056
6057 for(int32_t i=0; i<expansionsize; i++)
6058 {
6059 if(!p_getc(&tempbyte,f,true))
6060 {
6061 return qe_invalid;
6062 }
6063 }
6064 }
6065 //shops v8
6066
6067
6068
2/2
✓ Branch 0 taken 55 times.
✓ Branch 1 taken 3 times.
58 if(s_version >= 8)
6069 {
6070
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 3 times.
51 for(int32_t i=0; i<shops; i++)
6071 {
6072
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 48 times.
192 for(int32_t j=0; j<3; j++)
6073 {
6074
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetw(&temp_misc.shop[i].str[j],f,true))
6075 return qe_invalid;
6076 144 }
6077 48 }
6078 3 }
6079
6080 58 memset(&temp_misc.questmisc, 0, sizeof(int32_t)*32);
6081 58 memset(&temp_misc.questmisc_strings, 0, sizeof(char)*4096);
6082 58 memset(&temp_misc.zscript_last_compiled_version, 0, sizeof(int32_t));
6083
6084 //v9 includes quest misc[32]
6085
2/2
✓ Branch 0 taken 55 times.
✓ Branch 1 taken 3 times.
58 if(s_version >= 9)
6086 {
6087
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 for ( int32_t q = 0; q < 32; q++ )
6088 {
6089
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_igetl(&temp_misc.questmisc[q],f,true))
6090 return qe_invalid;
6091 96 }
6092
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 for ( int32_t q = 0; q < 32; q++ )
6093 {
6094
2/2
✓ Branch 0 taken 12288 times.
✓ Branch 1 taken 96 times.
12384 for ( int32_t j = 0; j < 128; j++ )
6095
1/2
✓ Branch 0 taken 12288 times.
✗ Branch 1 not taken.
12288 if(!p_getc(&temp_misc.questmisc_strings[q][j],f,true))
6096 return qe_invalid;
6097 96 }
6098 3 }
6099
6100
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 55 times.
58 if(s_version >= 11 )
6101 {
6102
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_igetl(&temp_misc.zscript_last_compiled_version,f,true))
6103 return qe_invalid;
6104 3 }
6105
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
55 else if(s_version < 11 )
6106 {
6107 55 temp_misc.zscript_last_compiled_version = -1;
6108 55 }
6109
6110 58 FFCore.quest_format[vLastCompile] = temp_misc.zscript_last_compiled_version;
6111
6112
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 55 times.
58 if(s_version >= 12)
6113 {
6114 byte spr;
6115
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 3 times.
771 for(int32_t q = 0; q < sprMAX; ++q)
6116 {
6117
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_getc(&spr,f,true))
6118 return qe_invalid;
6119 768 temp_misc.sprites[q] = spr;
6120 768 }
6121 3 }
6122 else
6123 {
6124 55 memset(&(temp_misc.sprites), 0, sizeof(temp_misc.sprites));
6125 //temp_misc.sprites[sprFALL] = ;
6126 }
6127
6128
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 55 times.
58 if(s_version >= 13)
6129 {
6130
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 3 times.
195 for(size_t q = 0; q < 64; ++q)
6131 {
6132 192 bottletype* bt = &(temp_misc.bottle_types[q]);
6133
1/2
✓ Branch 0 taken 192 times.
✗ Branch 1 not taken.
192 if (!pfread(bt->name, 32, f, true))
6134 return qe_invalid;
6135
2/2
✓ Branch 0 taken 576 times.
✓ Branch 1 taken 192 times.
768 for(size_t j = 0; j < 3; ++j)
6136 {
6137
1/2
✓ Branch 0 taken 576 times.
✗ Branch 1 not taken.
576 if (!p_getc(&(bt->counter[j]), f, true))
6138 return qe_invalid;
6139
1/2
✓ Branch 0 taken 576 times.
✗ Branch 1 not taken.
576 if (!p_igetw(&(bt->amount[j]), f, true))
6140 return qe_invalid;
6141 576 }
6142
1/2
✓ Branch 0 taken 192 times.
✗ Branch 1 not taken.
192 if (!p_getc(&(bt->flags), f, true))
6143 return qe_invalid;
6144
1/2
✓ Branch 0 taken 192 times.
✗ Branch 1 not taken.
192 if (!p_getc(&(bt->next_type), f, true))
6145 return qe_invalid;
6146 192 }
6147
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 3 times.
771 for(size_t q = 0; q < 256; ++q)
6148 {
6149 768 bottleshoptype* bst = &(temp_misc.bottle_shop_types[q]);
6150
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if (!pfread(bst->name, 32, f, true))
6151 return qe_invalid;
6152
2/2
✓ Branch 0 taken 2304 times.
✓ Branch 1 taken 768 times.
3072 for(size_t j = 0; j < 3; ++j)
6153 {
6154
1/2
✓ Branch 0 taken 2304 times.
✗ Branch 1 not taken.
2304 if (!p_getc(&(bst->fill[j]), f, true))
6155 return qe_invalid;
6156
1/2
✓ Branch 0 taken 2304 times.
✗ Branch 1 not taken.
2304 if (!p_igetw(&(bst->comb[j]), f, true))
6157 return qe_invalid;
6158
1/2
✓ Branch 0 taken 2304 times.
✗ Branch 1 not taken.
2304 if (!p_getc(&(bst->cset[j]), f, true))
6159 return qe_invalid;
6160
1/2
✓ Branch 0 taken 2304 times.
✗ Branch 1 not taken.
2304 if (!p_igetw(&(bst->price[j]), f, true))
6161 return qe_invalid;
6162
1/2
✓ Branch 0 taken 2304 times.
✗ Branch 1 not taken.
2304 if (!p_igetw(&(bst->str[j]), f, true))
6163 return qe_invalid;
6164 2304 }
6165 768 }
6166 3 }
6167 else
6168 {
6169
2/2
✓ Branch 0 taken 3520 times.
✓ Branch 1 taken 55 times.
3575 for(size_t q = 0; q < 64; ++q)
6170 3520 temp_misc.bottle_types[q].clear();
6171
2/2
✓ Branch 0 taken 14080 times.
✓ Branch 1 taken 55 times.
14135 for(size_t q = 0; q < 256; ++q)
6172 14080 temp_misc.bottle_shop_types[q].clear();
6173 }
6174
6175
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 55 times.
58 if(s_version >= 14)
6176 {
6177 byte msfx;
6178
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 3 times.
771 for(int32_t q = 0; q < sfxMAX; ++q)
6179 {
6180
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_getc(&msfx,f,true))
6181 return qe_invalid;
6182 768 temp_misc.miscsfx[q] = msfx;
6183 768 }
6184 3 }
6185 else
6186 {
6187 55 memset(&(temp_misc.miscsfx), 0, sizeof(temp_misc.miscsfx));
6188 55 temp_misc.miscsfx[sfxBUSHGRASS] = WAV_ZN1GRASSCUT;
6189 55 temp_misc.miscsfx[sfxLOWHEART] = WAV_ER;
6190 }
6191
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 55 times.
58 if(s_version < 15)
6192 {
6193 55 temp_misc.miscsfx[sfxHURTPLAYER] = WAV_OUCH;
6194 55 temp_misc.miscsfx[sfxHAMMERPOUND] = WAV_ZN1HAMMERPOST;
6195 55 temp_misc.miscsfx[sfxSUBSCR_ITEM_ASSIGN] = WAV_PLACE;
6196 55 temp_misc.miscsfx[sfxSUBSCR_CURSOR_MOVE] = WAV_CHIME;
6197 55 temp_misc.miscsfx[sfxREFILL] = WAV_MSG;
6198 55 temp_misc.miscsfx[sfxDRAIN] = WAV_MSG;
6199 55 }
6200
6201
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 if(keepdata==true)
6202 {
6203 58 memcpy(Misc, &temp_misc, sizeof(temp_misc));
6204 58 }
6205
6206 58 return 0;
6207 58 }
6208
6209 extern char *item_string[ITEMCNT];
6210 extern const char *old_item_string[iLast];
6211 extern char *weapon_string[WPNCNT];
6212 extern const char *old_weapon_string[wLast];
6213
6214 58 int32_t readitems(PACKFILE *f, word version, word build, bool keepdata, bool zgpmode)
6215 {
6216 byte padding;
6217 int32_t dummy;
6218 58 word items_to_read=MAXITEMS;
6219 itemdata tempitem;
6220 58 word s_version=0, s_cversion=0;
6221 word dummy_word;
6222
6223
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(version < 0x186)
6224 {
6225 items_to_read=64;
6226 }
6227
6228
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 if(version > 0x192)
6229 {
6230 58 items_to_read=0;
6231
6232 //section version info
6233
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(!p_igetw(&s_version,f,true))
6234 {
6235 return qe_invalid;
6236 }
6237
6238 58 FFCore.quest_format[vItems] = s_version;
6239
6240 //al_trace("Items version %d\n", s_version);
6241
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(!p_igetw(&s_cversion,f,true))
6242 {
6243 return qe_invalid;
6244 }
6245
6246 //section size
6247
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(!p_igetl(&dummy,f,true))
6248 {
6249 return qe_invalid;
6250 }
6251
6252 //finally... section data
6253
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(!p_igetw(&items_to_read,f,true))
6254 {
6255 return qe_invalid;
6256 }
6257 58 }
6258
6259
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(s_version>1)
6260 {
6261
2/2
✓ Branch 0 taken 14848 times.
✓ Branch 1 taken 58 times.
14906 for(int32_t i=0; i<items_to_read; i++)
6262 {
6263 char tempname[64];
6264
6265
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!pfread(tempname, 64, f, keepdata))
6266 {
6267 return qe_invalid;
6268 }
6269
6270
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14848 times.
14848 if(keepdata)
6271 {
6272 14848 strcpy(item_string[i], tempname);
6273 14848 }
6274 14848 }
6275 58 }
6276 else
6277 {
6278 if(keepdata)
6279 {
6280 for(int32_t i=0; i<ITEMCNT; i++)
6281 {
6282 reset_itemname(i);
6283 }
6284 }
6285 }
6286
6287
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 if(keepdata)
6288 {
6289
2/2
✓ Branch 0 taken 14848 times.
✓ Branch 1 taken 58 times.
14906 for(int32_t i=0; i<MAXITEMS; i++)
6290 {
6291 14848 itemdata& id = itemsbuf[i];
6292 14848 memset(&id, 0, sizeof(itemdata));
6293 14848 id.count=-1;
6294 14848 id.playsound=WAV_SCALE;
6295 14848 reset_itembuf(&id,i);
6296 14848 }
6297 58 }
6298
6299
2/2
✓ Branch 0 taken 14848 times.
✓ Branch 1 taken 58 times.
14906 for(int32_t i=0; i<items_to_read; i++)
6300 {
6301 14848 memset(&tempitem, 0, sizeof(itemdata));
6302 14848 reset_itembuf(&tempitem,i);
6303
6304
6305
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 14080 times.
14848 if ( s_version > 35 ) //expanded tiles
6306 {
6307
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_igetl(&tempitem.tile,f,true))
6308 {
6309 return qe_invalid;
6310 }
6311 768 }
6312 else
6313 {
6314
1/2
✓ Branch 0 taken 14080 times.
✗ Branch 1 not taken.
14080 if(!p_igetw(&tempitem.tile,f,true))
6315 {
6316 return qe_invalid;
6317 }
6318 }
6319
6320
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_getc(&tempitem.misc_flags,f,true))
6321 {
6322 return qe_invalid;
6323 }
6324
6325
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_getc(&tempitem.csets,f,true))
6326 {
6327 return qe_invalid;
6328 }
6329
6330
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_getc(&tempitem.frames,f,true))
6331 {
6332 return qe_invalid;
6333 }
6334
6335
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_getc(&tempitem.speed,f,true))
6336 {
6337 return qe_invalid;
6338 }
6339
6340
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_getc(&tempitem.delay,f,true))
6341 {
6342 return qe_invalid;
6343 }
6344
6345
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(version < 0x193)
6346 {
6347 if(!p_getc(&padding,f,true))
6348 {
6349 return qe_invalid;
6350 }
6351
6352 if((version < 0x192)||((version == 0x192)&&(build<186)))
6353 {
6354 switch(i)
6355 {
6356 case iShield:
6357 tempitem.ltm=get_bit(quest_rules,qr_BSZELDA)?-12:10;
6358 break;
6359
6360 case iMShield:
6361 tempitem.ltm=get_bit(quest_rules,qr_BSZELDA)?-6:-10;
6362 break;
6363
6364 default:
6365 tempitem.ltm=0;
6366 break;
6367 }
6368
6369 tempitem.count=-1;
6370 tempitem.flags=tempitem.wpn=tempitem.wpn2=tempitem.wpn3=tempitem.wpn3=tempitem.pickup_hearts=
6371 tempitem.misc1=tempitem.misc2=tempitem.usesound=0;
6372 tempitem.family=0xFF;
6373 tempitem.playsound=WAV_SCALE;
6374 reset_itembuf(&tempitem,i);
6375
6376 if(keepdata==true)
6377 {
6378 memcpy(&itemsbuf[i], &tempitem, sizeof(itemdata));
6379 }
6380
6381 continue;
6382 }
6383 }
6384
6385
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_igetl(&tempitem.ltm,f,true))
6386 {
6387 return qe_invalid;
6388 }
6389
6390
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(version < 0x193)
6391 {
6392 for(int32_t q=0; q<12; q++)
6393 {
6394 if(!p_getc(&padding,f,true))
6395 {
6396 return qe_invalid;
6397 }
6398 }
6399 }
6400
6401
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(s_version>1)
6402 {
6403
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 14080 times.
14848 if ( s_version >= 31 )
6404 {
6405
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_igetl(&tempitem.family,f,true))
6406 {
6407 return qe_invalid;
6408 }
6409 768 }
6410 else
6411 {
6412
1/2
✓ Branch 0 taken 14080 times.
✗ Branch 1 not taken.
14080 if(!p_getc(&tempitem.family,f,true))
6413 {
6414 return qe_invalid;
6415 }
6416 }
6417
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(s_version < 16)
6418 if(tempitem.family == 0xFF)
6419 tempitem.family = itype_misc;
6420
6421
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_getc(&tempitem.fam_type,f,true))
6422 {
6423 return qe_invalid;
6424 }
6425
6426
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(s_version>5)
6427 {
6428
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 14080 times.
14848 if(s_version>=31)
6429 {
6430
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_igetl(&tempitem.power,f,true))
6431 {
6432 return qe_invalid;
6433 }
6434 768 }
6435 else
6436 {
6437
1/2
✓ Branch 0 taken 14080 times.
✗ Branch 1 not taken.
14080 if(!p_getc(&tempitem.power,f,true))
6438 {
6439 return qe_invalid;
6440 }
6441 }
6442
6443 //converted flags from 16b to 32b -Z
6444
2/2
✓ Branch 0 taken 14080 times.
✓ Branch 1 taken 768 times.
14848 if ( s_version < 41 )
6445 {
6446
1/2
✓ Branch 0 taken 14080 times.
✗ Branch 1 not taken.
14080 if(!p_igetw(&tempitem.flags,f,true))
6447 {
6448 return qe_invalid;
6449 }
6450 14080 }
6451 else
6452 {
6453
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_igetl(&tempitem.flags,f,true))
6454 {
6455 return qe_invalid;
6456 }
6457 }
6458 14848 }
6459 else
6460 {
6461 //tempitem.power = tempitem.fam_type;
6462 char tempchar;
6463
6464 if(!p_getc(&tempchar,f,true))
6465 {
6466 return qe_invalid;
6467 }
6468
6469 tempitem.flags |= (tempchar ? ITEM_GAMEDATA : 0);
6470 }
6471
6472
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_igetw(&tempitem.script,f,true))
6473 {
6474 return qe_invalid;
6475 }
6476
6477
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(s_version<=3)
6478 {
6479 if(tempitem.script > NUMSCRIPTITEM)
6480 {
6481 tempitem.script = 0;
6482 }
6483 }
6484
6485
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_getc(&tempitem.count,f,true))
6486 {
6487 return qe_invalid;
6488 }
6489
6490
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_igetw(&tempitem.amount,f,true))
6491 {
6492 return qe_invalid;
6493 }
6494
6495
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_igetw(&tempitem.collect_script,f,true))
6496 {
6497 return qe_invalid;
6498 }
6499
6500
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(s_version<=3)
6501 {
6502 if(tempitem.collect_script > NUMSCRIPTITEM)
6503 {
6504 tempitem.collect_script = 0;
6505 }
6506 }
6507
6508
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_igetw(&tempitem.setmax,f,true))
6509 {
6510 return qe_invalid;
6511 }
6512
6513
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_igetw(&tempitem.max,f,true))
6514 {
6515 return qe_invalid;
6516 }
6517
6518
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_getc(&tempitem.playsound,f,true))
6519 {
6520 return qe_invalid;
6521 }
6522
6523
2/2
✓ Branch 0 taken 118784 times.
✓ Branch 1 taken 14848 times.
133632 for(int32_t j=0; j<8; j++)
6524 {
6525
1/2
✓ Branch 0 taken 118784 times.
✗ Branch 1 not taken.
118784 if(!p_igetl(&tempitem.initiald[j],f,true))
6526 {
6527 return qe_invalid;
6528 }
6529 118784 }
6530
6531
2/2
✓ Branch 0 taken 29696 times.
✓ Branch 1 taken 14848 times.
44544 for(int32_t j=0; j<2; j++)
6532 {
6533
1/2
✓ Branch 0 taken 29696 times.
✗ Branch 1 not taken.
29696 if(!p_getc(&tempitem.initiala[j],f,true))
6534 {
6535 return qe_invalid;
6536 }
6537 29696 }
6538
6539
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14848 times.
14848 if(s_version>4)
6540 {
6541
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(s_version>5)
6542 {
6543
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_getc(&tempitem.wpn,f,true))
6544 {
6545 return qe_invalid;
6546 }
6547
6548
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_getc(&tempitem.wpn2,f,true))
6549 {
6550 return qe_invalid;
6551 }
6552
6553
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_getc(&tempitem.wpn3,f,true))
6554 {
6555 return qe_invalid;
6556 }
6557
6558
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_getc(&tempitem.wpn4,f,true))
6559 {
6560 return qe_invalid;
6561 }
6562
6563
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14848 times.
14848 if(s_version>=15)
6564 {
6565
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_getc(&tempitem.wpn5,f,true))
6566 {
6567 return qe_invalid;
6568 }
6569
6570
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_getc(&tempitem.wpn6,f,true))
6571 {
6572 return qe_invalid;
6573 }
6574
6575
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_getc(&tempitem.wpn7,f,true))
6576 {
6577 return qe_invalid;
6578 }
6579
6580
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_getc(&tempitem.wpn8,f,true))
6581 {
6582 return qe_invalid;
6583 }
6584
6585
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_getc(&tempitem.wpn9,f,true))
6586 {
6587 return qe_invalid;
6588 }
6589
6590
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_getc(&tempitem.wpn10,f,true))
6591 {
6592 return qe_invalid;
6593 }
6594 14848 }
6595
6596
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_getc(&tempitem.pickup_hearts,f,true))
6597 {
6598 return qe_invalid;
6599 }
6600
6601
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14848 times.
14848 if(s_version<15)
6602 {
6603 if(!p_igetw(&dummy_word,f,true))
6604 {
6605 return qe_invalid;
6606 }
6607
6608 tempitem.misc1=dummy_word;
6609
6610 if(!p_igetw(&dummy_word,f,true))
6611 {
6612 return qe_invalid;
6613 }
6614
6615 tempitem.misc2=dummy_word;
6616 }
6617 else
6618 {
6619
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_igetl(&tempitem.misc1,f,true))
6620 {
6621 return qe_invalid;
6622 }
6623
6624
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_igetl(&tempitem.misc2,f,true))
6625 {
6626 return qe_invalid;
6627 }
6628
6629 // Version 24: shICE -> shSCRIPT; previously, all shields could block script weapons
6630
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(s_version<24)
6631 {
6632 if(tempitem.family==itype_shield)
6633 {
6634 tempitem.misc1|=shSCRIPT;
6635 }
6636 }
6637 }
6638
6639
2/2
✓ Branch 0 taken 14080 times.
✓ Branch 1 taken 768 times.
14848 if(s_version < 53)
6640 {
6641 byte tempbyte;
6642
1/2
✓ Branch 0 taken 14080 times.
✗ Branch 1 not taken.
14080 if(!p_getc(&tempbyte,f,true))
6643 {
6644 return qe_invalid;
6645 }
6646 14080 tempitem.cost_amount[0] = tempbyte;
6647 14080 }
6648 else
6649 {
6650
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 768 times.
2304 for(auto q = 0; q < 2; ++q)
6651 {
6652
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(!p_igetw(&tempitem.cost_amount[q],f,true))
6653 {
6654 return qe_invalid;
6655 }
6656 1536 }
6657 }
6658 14848 }
6659 else
6660 {
6661 char tempchar;
6662
6663 if(!p_getc(&tempchar,f,true))
6664 {
6665 return qe_invalid;
6666 }
6667
6668 tempitem.flags |= (tempchar ? ITEM_EDIBLE : 0);
6669 }
6670
6671 // June 2007: more misc. attributes
6672
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14848 times.
14848 if(s_version>=12)
6673 {
6674
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14848 times.
14848 if(s_version<15)
6675 {
6676 if(!p_igetw(&dummy_word,f,true))
6677 {
6678 return qe_invalid;
6679 }
6680
6681 tempitem.misc3=dummy_word;
6682
6683 if(!p_igetw(&dummy_word,f,true))
6684 {
6685 return qe_invalid;
6686 }
6687
6688 tempitem.misc4=dummy_word;
6689 }
6690 else
6691 {
6692
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_igetl(&tempitem.misc3,f,true))
6693 {
6694 return qe_invalid;
6695 }
6696
6697
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_igetl(&tempitem.misc4,f,true))
6698 {
6699 return qe_invalid;
6700 }
6701
6702
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_igetl(&tempitem.misc5,f,true))
6703 {
6704 return qe_invalid;
6705 }
6706
6707
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_igetl(&tempitem.misc6,f,true))
6708 {
6709 return qe_invalid;
6710 }
6711
6712
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_igetl(&tempitem.misc7,f,true))
6713 {
6714 return qe_invalid;
6715 }
6716
6717
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_igetl(&tempitem.misc8,f,true))
6718 {
6719 return qe_invalid;
6720 }
6721
6722
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_igetl(&tempitem.misc9,f,true))
6723 {
6724 return qe_invalid;
6725 }
6726
6727
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_igetl(&tempitem.misc10,f,true))
6728 {
6729 return qe_invalid;
6730 }
6731 }
6732
6733
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_getc(&tempitem.usesound,f,true))
6734 {
6735 return qe_invalid;
6736 }
6737
6738
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 14080 times.
14848 if(s_version >= 49)
6739 {
6740
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_getc(&tempitem.usesound2,f,true))
6741 {
6742 return qe_invalid;
6743 }
6744 768 }
6745 14080 else tempitem.usesound2 = 0;
6746
6747
3/4
✓ Branch 0 taken 14080 times.
✓ Branch 1 taken 768 times.
✓ Branch 2 taken 14080 times.
✗ Branch 3 not taken.
14848 if(s_version < 50 && tempitem.family == itype_mirror)
6748 {
6749 //Split continue/dmap warp effect/sfx, port for old
6750 tempitem.misc2 = tempitem.misc1;
6751 tempitem.usesound2 = tempitem.usesound;
6752 }
6753 14848 }
6754 14848 }
6755
6756
2/2
✓ Branch 0 taken 14080 times.
✓ Branch 1 taken 768 times.
14848 if ( s_version >= 26 ) //! New itemdata vars for weapon editor. -Z
6757 { // temp.useweapon, temp.usedefence, temp.weaprange, temp.weap_pattern[ITEM_MOVEMENT_PATTERNS]
6758
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_getc(&tempitem.useweapon,f,true))
6759 {
6760 return qe_invalid;
6761 }
6762
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_getc(&tempitem.usedefence,f,true))
6763 {
6764 return qe_invalid;
6765 }
6766
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_igetl(&tempitem.weaprange,f,true))
6767 {
6768 return qe_invalid;
6769 }
6770
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_igetl(&tempitem.weapduration,f,true))
6771 {
6772 return qe_invalid;
6773 }
6774
2/2
✓ Branch 0 taken 7680 times.
✓ Branch 1 taken 768 times.
8448 for ( int32_t q = 0; q < ITEM_MOVEMENT_PATTERNS; q++ )
6775 {
6776
1/2
✓ Branch 0 taken 7680 times.
✗ Branch 1 not taken.
7680 if(!p_igetl(&tempitem.weap_pattern[q],f,true))
6777 {
6778 return qe_invalid;
6779 }
6780 7680 }
6781 768 }
6782
6783
2/2
✓ Branch 0 taken 14080 times.
✓ Branch 1 taken 768 times.
14848 if ( s_version >= 27 ) //! New itemdata vars for weapon editor. -Z
6784 { // temp.useweapon, temp.usedefence, temp.weaprange, temp.weap_pattern[ITEM_MOVEMENT_PATTERNS]
6785
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_igetl(&tempitem.duplicates,f,true))
6786 {
6787 return qe_invalid;
6788 }
6789
2/2
✓ Branch 0 taken 6144 times.
✓ Branch 1 taken 768 times.
6912 for ( int32_t q = 0; q < INITIAL_D; q++ )
6790 {
6791
1/2
✓ Branch 0 taken 6144 times.
✗ Branch 1 not taken.
6144 if(!p_igetl(&tempitem.weap_initiald[q],f,true))
6792 {
6793 return qe_invalid;
6794 }
6795 6144 }
6796
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 768 times.
2304 for ( int32_t q = 0; q < INITIAL_A; q++ )
6797 {
6798
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(!p_getc(&tempitem.weap_initiala[q],f,true))
6799 {
6800 return qe_invalid;
6801 }
6802 1536 }
6803
6804
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_getc(&tempitem.drawlayer,f,true))
6805 {
6806 return qe_invalid;
6807 }
6808
6809
6810
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_igetl(&tempitem.hxofs,f,true))
6811 {
6812 return qe_invalid;
6813 }
6814
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_igetl(&tempitem.hyofs,f,true))
6815 {
6816 return qe_invalid;
6817 }
6818
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_igetl(&tempitem.hxsz,f,true))
6819 {
6820 return qe_invalid;
6821 }
6822
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_igetl(&tempitem.hysz,f,true))
6823 {
6824 return qe_invalid;
6825 }
6826
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_igetl(&tempitem.hzsz,f,true))
6827 {
6828 return qe_invalid;
6829 }
6830
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_igetl(&tempitem.xofs,f,true))
6831 {
6832 return qe_invalid;
6833 }
6834
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_igetl(&tempitem.yofs,f,true))
6835 {
6836 return qe_invalid;
6837 }
6838
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_igetl(&tempitem.weap_hxofs,f,true))
6839 {
6840 return qe_invalid;
6841 }
6842
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_igetl(&tempitem.weap_hyofs,f,true))
6843 {
6844 return qe_invalid;
6845 }
6846
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_igetl(&tempitem.weap_hxsz,f,true))
6847 {
6848 return qe_invalid;
6849 }
6850
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_igetl(&tempitem.weap_hysz,f,true))
6851 {
6852 return qe_invalid;
6853 }
6854
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_igetl(&tempitem.weap_hzsz,f,true))
6855 {
6856 return qe_invalid;
6857 }
6858
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_igetl(&tempitem.weap_xofs,f,true))
6859 {
6860 return qe_invalid;
6861 }
6862
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_igetl(&tempitem.weap_yofs,f,true))
6863 {
6864 return qe_invalid;
6865 }
6866
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_igetw(&tempitem.weaponscript,f,true))
6867 {
6868 return qe_invalid;
6869 }
6870
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_igetl(&tempitem.wpnsprite,f,true))
6871 {
6872 return qe_invalid;
6873 }
6874 768 auto num_cost_tmr = (s_version > 52 ? 2 : 1);
6875
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 768 times.
2304 for(auto q = 0; q < num_cost_tmr; ++q)
6876 {
6877
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(!p_igetl(&tempitem.magiccosttimer[q],f,true))
6878 {
6879 return qe_invalid;
6880 }
6881 1536 }
6882
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 768 times.
768 for(auto q = num_cost_tmr; q < 2; ++q)
6883 tempitem.magiccosttimer[q] = 0;
6884 768 }
6885
2/2
✓ Branch 0 taken 14080 times.
✓ Branch 1 taken 768 times.
14848 if ( s_version >= 28 ) //! New itemdata vars for weapon editor. -Z
6886 {
6887 //Item Size FLags, TileWidth, TileHeight
6888
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_igetl(&tempitem.overrideFLAGS,f,true))
6889 {
6890 return qe_invalid;
6891 }
6892
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_igetl(&tempitem.tilew,f,true))
6893 {
6894 return qe_invalid;
6895 }
6896
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_igetl(&tempitem.tileh,f,true))
6897 {
6898 return qe_invalid;
6899 }
6900 768 }
6901
2/2
✓ Branch 0 taken 14080 times.
✓ Branch 1 taken 768 times.
14848 if ( s_version >= 29 ) //! More new vars.
6902 {
6903 //Item Size FLags, TileWidth, TileHeight
6904
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_igetl(&tempitem.weapoverrideFLAGS,f,true))
6905 {
6906 return qe_invalid;
6907 }
6908
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_igetl(&tempitem.weap_tilew,f,true))
6909 {
6910 return qe_invalid;
6911 }
6912
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_igetl(&tempitem.weap_tileh,f,true))
6913 {
6914 return qe_invalid;
6915 }
6916 768 }
6917
2/2
✓ Branch 0 taken 14080 times.
✓ Branch 1 taken 768 times.
14848 if ( s_version >= 30 ) //! More new vars.
6918 {
6919 //Pickup Type
6920
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_igetl(&tempitem.pickup,f,true))
6921 {
6922 return qe_invalid;
6923 }
6924 768 }
6925
2/2
✓ Branch 0 taken 14080 times.
✓ Branch 1 taken 768 times.
14848 if ( s_version >= 32 ) //! More new vars.
6926 {
6927 //Pickup Type
6928
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_igetw(&tempitem.pstring,f,true))
6929 {
6930 return qe_invalid;
6931 }
6932 768 }
6933
2/2
✓ Branch 0 taken 14080 times.
✓ Branch 1 taken 768 times.
14848 if ( s_version >= 33 ) //! More new vars.
6934 {
6935 //Pickup Type
6936
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_igetw(&tempitem.pickup_string_flags,f,true))
6937 {
6938 return qe_invalid;
6939 }
6940 768 }
6941
2/2
✓ Branch 0 taken 14080 times.
✓ Branch 1 taken 768 times.
14848 if ( s_version >= 34 ) //! cost counter
6942 {
6943
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 768 times.
768 if(s_version < 53)
6944 {
6945 if(!p_getc(&tempitem.cost_counter[0],f,true))
6946 {
6947 return qe_invalid;
6948 }
6949 }
6950 else
6951 {
6952
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 768 times.
2304 for(auto q = 0; q < 2; ++q)
6953 {
6954
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(!p_getc(&tempitem.cost_counter[q],f,true))
6955 {
6956 return qe_invalid;
6957 }
6958 1536 }
6959 }
6960 768 }
6961
2/2
✓ Branch 0 taken 14080 times.
✓ Branch 1 taken 768 times.
14848 if ( s_version >= 44 ) //! sprite scripts
6962 {
6963
2/2
✓ Branch 0 taken 6144 times.
✓ Branch 1 taken 768 times.
6912 for ( int32_t q = 0; q < 8; q++ )
6964 {
6965
2/2
✓ Branch 0 taken 399360 times.
✓ Branch 1 taken 6144 times.
405504 for ( int32_t w = 0; w < 65; w++ )
6966 {
6967
1/2
✓ Branch 0 taken 399360 times.
✗ Branch 1 not taken.
399360 if(!p_getc(&(tempitem.initD_label[q][w]),f,keepdata))
6968 {
6969 return qe_invalid;
6970 }
6971 399360 }
6972
2/2
✓ Branch 0 taken 399360 times.
✓ Branch 1 taken 6144 times.
405504 for ( int32_t w = 0; w < 65; w++ )
6973 {
6974
1/2
✓ Branch 0 taken 399360 times.
✗ Branch 1 not taken.
399360 if(!p_getc(&(tempitem.weapon_initD_label[q][w]),f,keepdata))
6975 {
6976 return qe_invalid;
6977 }
6978 399360 }
6979
2/2
✓ Branch 0 taken 399360 times.
✓ Branch 1 taken 6144 times.
405504 for ( int32_t w = 0; w < 65; w++ )
6980 {
6981
1/2
✓ Branch 0 taken 399360 times.
✗ Branch 1 not taken.
399360 if(!p_getc(&(tempitem.sprite_initD_label[q][w]),f,keepdata))
6982 {
6983 return qe_invalid;
6984 }
6985 399360 }
6986
1/2
✓ Branch 0 taken 6144 times.
✗ Branch 1 not taken.
6144 if(!p_igetl(&(tempitem.sprite_initiald[q]),f,keepdata))
6987 {
6988 return qe_invalid;
6989 }
6990
6991 6144 }
6992
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 768 times.
2304 for ( int32_t q = 0; q < 2; q++ )
6993 {
6994
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(!p_getc(&(tempitem.sprite_initiala[q]),f,keepdata))
6995 {
6996 return qe_invalid;
6997 }
6998 1536 }
6999 //Pickup Type
7000
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_igetw(&tempitem.sprite_script,f,true))
7001 {
7002 return qe_invalid;
7003 }
7004 768 }
7005
2/2
✓ Branch 0 taken 14080 times.
✓ Branch 1 taken 768 times.
14848 if ( s_version >= 48 ) //! pickup flags
7006 {
7007
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_getc(&(tempitem.pickupflag),f,keepdata))
7008 {
7009 return qe_invalid;
7010 }
7011 768 }
7012 14848 }
7013 else
7014 {
7015 tempitem.count=-1;
7016 tempitem.family=itype_misc;
7017 tempitem.flags=tempitem.wpn=tempitem.wpn2=tempitem.wpn3=tempitem.wpn3=tempitem.pickup_hearts=tempitem.misc1=tempitem.misc2=tempitem.usesound=0;
7018 tempitem.playsound=WAV_SCALE;
7019 reset_itembuf(&tempitem,i);
7020 }
7021
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 14080 times.
14848 if(s_version < 53)
7022 {
7023
4/4
✓ Branch 0 taken 13795 times.
✓ Branch 1 taken 165 times.
✓ Branch 2 taken 65 times.
✓ Branch 3 taken 55 times.
14080 switch(tempitem.family)
7024 {
7025 case itype_arrow:
7026 165 tempitem.cost_counter[1] = crARROWS;
7027 165 tempitem.cost_amount[1] = 1;
7028 165 break;
7029 case itype_bomb:
7030 65 tempitem.cost_counter[1] = crBOMBS;
7031 65 tempitem.cost_amount[1] = 1;
7032 65 break;
7033 case itype_sbomb:
7034 55 tempitem.cost_counter[1] = crSBOMBS;
7035 55 tempitem.cost_amount[1] = 1;
7036 55 break;
7037 default:
7038 13795 tempitem.cost_counter[1] = crNONE;
7039 13795 tempitem.cost_amount[1] = 0;
7040 13795 }
7041 14080 tempitem.magiccosttimer[1] = 0;
7042 14080 }
7043
7044
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(keepdata==true)
7045 {
7046 14848 memcpy(&itemsbuf[i], &tempitem, sizeof(itemdata));
7047 14848 }
7048 else if(zgpmode)
7049 {
7050 itemsbuf[i].tile=tempitem.tile;
7051 itemsbuf[i].misc_flags=tempitem.misc_flags;
7052 itemsbuf[i].csets=tempitem.csets;
7053 itemsbuf[i].frames=tempitem.frames;
7054 itemsbuf[i].speed=tempitem.speed;
7055 itemsbuf[i].delay=tempitem.delay;
7056 itemsbuf[i].ltm=tempitem.ltm;
7057 }
7058 14848 }
7059
7060 //////////////////////////////////////////////////////
7061 // Now do any updates because of new item additions
7062 // (These can't be done above because items_to_read
7063 // might be too low.)
7064 //////////////////////////////////////////////////////
7065
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 if(keepdata==true)
7066 {
7067
2/2
✓ Branch 0 taken 14848 times.
✓ Branch 1 taken 58 times.
14906 for(int32_t i=0; i<MAXITEMS; i++)
7068 {
7069 14848 memcpy(&tempitem, &itemsbuf[i], sizeof(itemdata));
7070
7071 //Account for older quests that didn't have an actual item for the used letter
7072
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 14848 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
14848 if(s_version < 2 && i==iLetterUsed)
7073 {
7074 reset_itembuf(&tempitem, iLetterUsed);
7075 strcpy(item_string[i],old_item_string[i]);
7076 tempitem.tile = itemsbuf[iLetter].tile;
7077 tempitem.csets = itemsbuf[iLetter].csets;
7078 tempitem.misc_flags = itemsbuf[iLetter].misc_flags;
7079 tempitem.frames = itemsbuf[iLetter].frames;
7080 tempitem.speed = itemsbuf[iLetter].speed;
7081 tempitem.ltm = itemsbuf[iLetter].ltm;
7082 }
7083
7084
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(s_version < 3)
7085 {
7086 switch(i)
7087 {
7088 case iRocsFeather:
7089 case iHoverBoots:
7090 case iSpinScroll:
7091 case iL2SpinScroll:
7092 case iCrossScroll:
7093 case iQuakeScroll:
7094 case iL2QuakeScroll:
7095 case iWhispRing:
7096 case iL2WhispRing:
7097 case iChargeRing:
7098 case iL2ChargeRing:
7099 case iPerilScroll:
7100 case iWalletL3:
7101 case iQuiverL4:
7102 case iBombBagL4:
7103 case iBracelet:
7104 case iL2Bracelet:
7105 case iOldGlove:
7106 case iL2Ladder:
7107 case iWealthMedal:
7108 case iL2WealthMedal:
7109 case iL3WealthMedal:
7110 reset_itembuf(&tempitem, i);
7111 strcpy(item_string[i],old_item_string[i]);
7112 break;
7113
7114 case iSShield:
7115 reset_itembuf(&tempitem, i);
7116 strcpy(item_string[i],old_item_string[i]);
7117 strcpy(item_string[iShield],old_item_string[iShield]);
7118 strcpy(item_string[iMShield],old_item_string[iMShield]);
7119 break;
7120 }
7121 }
7122
7123
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(s_version < 5)
7124 {
7125 switch(i)
7126 {
7127 case iHeartRing:
7128 case iL2HeartRing:
7129 case iL3HeartRing:
7130 case iMagicRing:
7131 case iL2MagicRing:
7132 case iL3MagicRing:
7133 case iL4MagicRing:
7134 reset_itembuf(&tempitem, i);
7135 strcpy(item_string[i],old_item_string[i]);
7136 break;
7137 }
7138 }
7139
7140
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(s_version < 6) // April 2007: Advanced item editing capabilities.
7141 {
7142 if(i!=iBPotion && i!=iRPotion)
7143 tempitem.flags |= get_bit(deprecated_rules,32) ? ITEM_KEEPOLD : 0;
7144
7145 switch(i)
7146 {
7147 case iTriforce:
7148 tempitem.fam_type=1;
7149 break;
7150
7151 case iBigTri:
7152 tempitem.fam_type=0;
7153 break;
7154
7155 case iBombs:
7156 tempitem.fam_type=i_bomb;
7157 tempitem.power=4;
7158 tempitem.wpn=wBOMB;
7159 tempitem.wpn2=wBOOM;
7160 tempitem.misc1 = 50;
7161
7162 if(get_bit(deprecated_rules,116)) tempitem.misc1 = 200; //qr_SLOWBOMBFUSES
7163
7164 break;
7165
7166 case iSBomb:
7167 tempitem.fam_type=i_sbomb;
7168 tempitem.power=16;
7169 tempitem.wpn=wSBOMB;
7170 tempitem.wpn2=wSBOOM;
7171 tempitem.misc1 = 50;
7172
7173 if(get_bit(deprecated_rules,116)) tempitem.misc1 = 400; //qr_SLOWBOMBFUSES
7174
7175 break;
7176
7177 case iBook:
7178 if(get_bit(deprecated_rules, 113))
7179 tempitem.wpn = wFIREMAGIC; //qr_FIREMAGICSPRITE
7180
7181 break;
7182
7183 case iSArrow:
7184 tempitem.wpn2 = get_bit(deprecated_rules,27) ? wSSPARKLE : 0; //qr_SASPARKLES
7185 tempitem.power=4;
7186 tempitem.flags|=ITEM_GAMEDATA;
7187 tempitem.wpn=wSARROW;
7188 break;
7189
7190 case iGArrow:
7191 tempitem.wpn2 = get_bit(deprecated_rules,28) ? wGSPARKLE : 0; //qr_GASPARKLES
7192 tempitem.power=8;
7193 tempitem.flags|=(ITEM_GAMEDATA|ITEM_FLAG1);
7194 tempitem.wpn=wGARROW;
7195 break;
7196
7197 case iBrang:
7198 tempitem.power=0;
7199 tempitem.wpn=wBRANG;
7200 tempitem.misc1=36;
7201 break;
7202
7203 case iMBrang:
7204 tempitem.wpn2 = get_bit(deprecated_rules,29) ? wMSPARKLE : 0; //qr_MBSPARKLES
7205 tempitem.power=0;
7206 tempitem.wpn=wMBRANG;
7207 break;
7208
7209 case iFBrang:
7210 tempitem.wpn3 = get_bit(deprecated_rules,30) ? wFSPARKLE : 0; //qr_FBSPARKLES
7211 tempitem.power=2;
7212 tempitem.wpn=wFBRANG;
7213 break;
7214
7215 case iBoots:
7216 tempitem.cost_amount[0] = get_bit(deprecated_rules,51) ? 1 : 0;
7217 tempitem.power=7;
7218 break;
7219
7220 case iWand:
7221 tempitem.cost_amount[0] = get_bit(deprecated_rules,49) ? 8 : 0;
7222 tempitem.power=2;
7223 tempitem.wpn=wWAND;
7224 tempitem.wpn3=wMAGIC;
7225 break;
7226
7227 case iBCandle:
7228 tempitem.cost_amount[0] = get_bit(deprecated_rules,50) ? 4 : 0;
7229 tempitem.power=1;
7230 tempitem.flags|=(ITEM_GAMEDATA|ITEM_FLAG1);
7231 tempitem.wpn3=wFIRE;
7232 break;
7233
7234 case iRCandle:
7235 tempitem.cost_amount[0] = get_bit(deprecated_rules,50) ? 4 : 0;
7236 tempitem.power=1;
7237 tempitem.wpn3=wFIRE;
7238 break;
7239
7240 case iSword:
7241 tempitem.power=1;
7242 tempitem.flags|= ITEM_FLAG4 |ITEM_FLAG2;
7243 tempitem.wpn=tempitem.wpn3=wSWORD;
7244 tempitem.wpn2=wSWORDSLASH;
7245 break;
7246
7247 case iWSword:
7248 tempitem.power=2;
7249 tempitem.flags|= ITEM_FLAG4 |ITEM_FLAG2;
7250 tempitem.wpn=tempitem.wpn3=wWSWORD;
7251 tempitem.wpn2=wWSWORDSLASH;
7252 break;
7253
7254 case iMSword:
7255 tempitem.power=4;
7256 tempitem.flags|= ITEM_FLAG4 |ITEM_FLAG2;
7257 tempitem.wpn=tempitem.wpn3=wMSWORD;
7258 tempitem.wpn2=wMSWORDSLASH;
7259 break;
7260
7261 case iXSword:
7262 tempitem.power=8;
7263 tempitem.flags|= ITEM_FLAG4 |ITEM_FLAG2;
7264 tempitem.wpn=tempitem.wpn3=wXSWORD;
7265 tempitem.wpn2=wXSWORDSLASH;
7266 break;
7267
7268 case iNayrusLove:
7269 tempitem.flags |= get_bit(deprecated_rules,76) ? ITEM_FLAG1 : 0;
7270 tempitem.flags |= get_bit(deprecated_rules,75) ? ITEM_FLAG2 : 0;
7271 tempitem.wpn=wNAYRUSLOVE1A;
7272 tempitem.wpn2=wNAYRUSLOVE1B;
7273 tempitem.wpn3=wNAYRUSLOVES1A;
7274 tempitem.wpn4=wNAYRUSLOVES1B;
7275 tempitem.wpn6=wNAYRUSLOVE2A;
7276 tempitem.wpn7=wNAYRUSLOVE2B;
7277 tempitem.wpn8=wNAYRUSLOVES2A;
7278 tempitem.wpn9=wNAYRUSLOVES2B;
7279 tempitem.wpn5 = iwNayrusLoveShieldFront;
7280 tempitem.wpn10 = iwNayrusLoveShieldBack;
7281 tempitem.misc1=512;
7282 tempitem.cost_amount[0]=64;
7283 break;
7284
7285 case iLens:
7286 tempitem.misc1=60;
7287 tempitem.flags |= get_bit(quest_rules,qr_ENABLEMAGIC) ? 0 : ITEM_RUPEE_MAGIC;
7288 tempitem.cost_amount[0] = get_bit(quest_rules,qr_ENABLEMAGIC) ? 2 : 1;
7289 break;
7290
7291 case iArrow:
7292 tempitem.power=2;
7293 tempitem.wpn=wARROW;
7294 break;
7295
7296 case iHoverBoots:
7297 tempitem.misc1=45;
7298 tempitem.wpn=iwHover;
7299 break;
7300
7301 case iDinsFire:
7302 tempitem.power=8;
7303 tempitem.wpn=wDINSFIRE1A;
7304 tempitem.wpn2=wDINSFIRE1B;
7305 tempitem.wpn3=wDINSFIRES1A;
7306 tempitem.wpn4=wDINSFIRES1B;
7307 tempitem.misc1 = 32;
7308 tempitem.misc2 = 200;
7309 tempitem.cost_amount[0]=32;
7310 break;
7311
7312 case iFaroresWind:
7313 tempitem.cost_amount[0]=32;
7314 break;
7315
7316 case iHookshot:
7317 tempitem.power=0;
7318 tempitem.flags&=~ITEM_FLAG1;
7319 tempitem.wpn=wHSHEAD;
7320 tempitem.wpn2=wHSCHAIN_H;
7321 tempitem.wpn4=wHSHANDLE;
7322 tempitem.wpn3=wHSCHAIN_V;
7323 tempitem.misc1=50;
7324 tempitem.misc2=100;
7325 break;
7326
7327 case iLongshot:
7328 tempitem.power=0;
7329 tempitem.flags&=~ITEM_FLAG1;
7330 tempitem.wpn=wLSHEAD;
7331 tempitem.wpn2=wLSCHAIN_H;
7332 tempitem.wpn4=wLSHANDLE;
7333 tempitem.wpn3=wLSCHAIN_V;
7334 tempitem.misc1=99;
7335 tempitem.misc2=100;
7336 break;
7337
7338 case iHammer:
7339 tempitem.power=4;
7340 tempitem.wpn=wHAMMER;
7341 tempitem.wpn2=iwHammerSmack;
7342 break;
7343
7344 case iCByrna:
7345 tempitem.power=1;
7346 tempitem.wpn=wCBYRNA;
7347 tempitem.wpn2=wCBYRNASLASH;
7348 tempitem.wpn3=wCBYRNAORB;
7349 tempitem.misc1=4;
7350 tempitem.misc2=16;
7351 tempitem.misc3=1;
7352 tempitem.cost_amount[0]=1;
7353 break;
7354
7355 case iWhistle:
7356 tempitem.wpn=wWIND;
7357 tempitem.misc1=3;
7358 tempitem.flags|=ITEM_FLAG1;
7359 break;
7360
7361 case iBRing:
7362 tempitem.power=2;
7363 tempitem.misc1=spBLUE;
7364 break;
7365
7366 case iRRing:
7367 tempitem.power=4;
7368 tempitem.misc1=spRED;
7369 break;
7370
7371 case iGRing:
7372 tempitem.power=8;
7373 tempitem.misc1=spGOLD;
7374 break;
7375
7376 case iSpinScroll:
7377 tempitem.power = 2;
7378 tempitem.misc1 = 1;
7379 break;
7380
7381 case iL2SpinScroll:
7382 tempitem.family=itype_spinscroll2;
7383 tempitem.fam_type=1;
7384 tempitem.cost_amount[0]=8;
7385 tempitem.power=2;
7386 tempitem.misc1 = 20;
7387 break;
7388
7389 case iQuakeScroll:
7390 tempitem.misc1=0x10;
7391 tempitem.misc2=64;
7392 break;
7393
7394 case iL2QuakeScroll:
7395 tempitem.family=itype_quakescroll2;
7396 tempitem.fam_type=1;
7397 tempitem.power = 2;
7398 tempitem.misc1=0x20;
7399 tempitem.misc2=192;
7400 tempitem.cost_amount[0]=8;
7401 break;
7402
7403 case iChargeRing:
7404 tempitem.misc1=64;
7405 tempitem.misc2=128;
7406 break;
7407
7408 case iL2ChargeRing:
7409 tempitem.misc1=32;
7410 tempitem.misc2=64;
7411 break;
7412
7413 case iOldGlove:
7414 tempitem.flags |= ITEM_FLAG1;
7415
7416 //fallthrough
7417 case iBombBagL4:
7418 case iWalletL3:
7419 case iQuiverL4:
7420 case iBracelet:
7421 tempitem.power = 1;
7422 break;
7423
7424 case iL2Bracelet:
7425 tempitem.power = 2;
7426 break;
7427
7428 case iMKey:
7429 tempitem.power=0xFF;
7430 tempitem.flags |= ITEM_FLAG1;
7431 break;
7432 }
7433 }
7434
7435
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(s_version < 7)
7436 {
7437 switch(i)
7438 {
7439 case iStoneAgony:
7440 case iStompBoots:
7441 case iPerilRing:
7442 case iWhimsicalRing:
7443 {
7444 reset_itembuf(&tempitem, i);
7445 strcpy(item_string[i],old_item_string[i]);
7446 break;
7447 }
7448 }
7449 }
7450
7451
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(s_version < 8) // May 2007: Some corrections.
7452 {
7453 switch(i)
7454 {
7455 case iMShield:
7456 tempitem.misc1|=shFLAME;
7457 tempitem.misc2|=shFIREBALL|shMAGIC;
7458
7459 if(get_bit(quest_rules, qr_SWORDMIRROR))
7460 {
7461 tempitem.misc2 |= shSWORD;
7462 }
7463
7464 // fallthrough
7465 case iShield:
7466 tempitem.misc1|=shFIREBALL|shSWORD|shMAGIC;
7467
7468 // fallthrough
7469 case iSShield:
7470 tempitem.misc1|=shROCK|shARROW|shBRANG|shSCRIPT;
7471
7472 if(get_bit(deprecated_rules,102)) //qr_REFLECTROCKS
7473 {
7474 tempitem.misc2 |= shROCK;
7475 }
7476
7477 break;
7478
7479 case iWhispRing:
7480 tempitem.power=1;
7481 tempitem.flags|=ITEM_GAMEDATA|ITEM_FLAG1;
7482 tempitem.misc1 = 3;
7483 break;
7484
7485 case iL2WhispRing:
7486 tempitem.power=0;
7487 tempitem.flags|=ITEM_GAMEDATA|ITEM_FLAG1;
7488 tempitem.misc1 = 3;
7489 break;
7490
7491 case iL2Ladder:
7492 case iBow:
7493 case iCByrna:
7494 tempitem.power = 1;
7495 break;
7496 }
7497 }
7498
7499
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 14848 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
14848 if(s_version < 9 && i==iClock)
7500 {
7501 tempitem.misc1 = get_bit(deprecated_rules, qr_TEMPCLOCKS_DEP) ? 256 : 0;
7502 }
7503
7504 //add the misc flag for bomb
7505
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 14848 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
14848 if(s_version < 10 && tempitem.family == itype_bomb)
7506 {
7507 tempitem.flags = (tempitem.flags & ~ITEM_FLAG1) | (get_bit(quest_rules, qr_LONGBOMBBOOM_DEP) ? ITEM_FLAG1 : 0);
7508 }
7509
7510
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 14848 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
14848 if(s_version < 11 && tempitem.family == itype_triforcepiece)
7511 {
7512 tempitem.flags = (tempitem.fam_type ? ITEM_GAMEDATA : 0);
7513 tempitem.playsound = (tempitem.fam_type ? WAV_SCALE : WAV_CLEARED);
7514 }
7515
7516
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(s_version < 12) // June 2007: More Misc. attributes.
7517 {
7518 switch(i)
7519 {
7520 case iFBrang:
7521 tempitem.misc4 |= shFIREBALL|shSWORD|shMAGIC;
7522
7523 //fallthrough
7524 case iMBrang:
7525 tempitem.misc3 |= shSWORD|shMAGIC;
7526
7527 //fallthrough
7528 case iHookshot:
7529 case iLongshot:
7530 //fallthrough
7531 tempitem.misc3 |= shFIREBALL;
7532
7533 case iBrang:
7534 tempitem.misc3 |= shBRANG|shROCK|shARROW;
7535 break;
7536 }
7537
7538 switch(tempitem.family)
7539 {
7540 case itype_hoverboots:
7541 tempitem.usesound = WAV_ZN1HOVER;
7542 break;
7543
7544 case itype_wand:
7545 case itype_book:
7546 tempitem.usesound = WAV_WAND;
7547 break;
7548
7549 case itype_arrow:
7550 tempitem.usesound = WAV_ARROW;
7551 break;
7552
7553 case itype_hookshot:
7554 tempitem.usesound = WAV_HOOKSHOT;
7555 break;
7556
7557 case itype_brang:
7558 tempitem.usesound = WAV_BRANG;
7559 break;
7560
7561 case itype_shield:
7562 tempitem.usesound = WAV_CHINK;
7563 break;
7564
7565 case itype_sword:
7566 tempitem.usesound = WAV_SWORD;
7567 break;
7568
7569 case itype_whistle:
7570 tempitem.usesound = WAV_WHISTLE;
7571 break;
7572
7573 case itype_hammer:
7574 tempitem.usesound = WAV_HAMMER;
7575 break;
7576
7577 case itype_dinsfire:
7578 tempitem.usesound = WAV_ZN1DINSFIRE;
7579 break;
7580
7581 case itype_faroreswind:
7582 tempitem.usesound = WAV_ZN1FARORESWIND;
7583 break;
7584
7585 case itype_nayruslove:
7586 tempitem.usesound = WAV_ZN1NAYRUSLOVE1;
7587 break;
7588
7589 case itype_bomb:
7590 case itype_sbomb:
7591 case itype_quakescroll:
7592 case itype_quakescroll2:
7593 tempitem.usesound = WAV_BOMB;
7594 break;
7595
7596 case itype_spinscroll:
7597 case itype_spinscroll2:
7598 tempitem.usesound = WAV_ZN1SPINATTACK;
7599 break;
7600 }
7601 }
7602
7603
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(s_version < 13) // July 2007
7604 {
7605 if(tempitem.family == itype_whistle)
7606 {
7607 tempitem.misc1 = (tempitem.power==2 ? 4 : 3);
7608 tempitem.power = 1;
7609 tempitem.flags|=ITEM_FLAG1;
7610 }
7611 else if(tempitem.family == itype_wand)
7612 tempitem.flags|=ITEM_FLAG1;
7613 else if(tempitem.family == itype_book)
7614 {
7615 tempitem.flags|=ITEM_FLAG1;
7616 tempitem.power = 2;
7617 }
7618 }
7619
7620
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(s_version < 14) // August 2007
7621 {
7622 if(tempitem.family == itype_fairy)
7623 {
7624 tempitem.usesound = WAV_SCALE;
7625
7626 if(tempitem.fam_type)
7627 tempitem.misc3=50;
7628 }
7629 else if(tempitem.family == itype_potion)
7630 {
7631 tempitem.flags |= ITEM_GAINOLD;
7632 }
7633 }
7634
7635
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(s_version < 17) // November 2007
7636 {
7637 if(tempitem.family == itype_candle && !tempitem.wpn3)
7638 {
7639 tempitem.wpn3 = wFIRE;
7640 }
7641 else if(tempitem.family == itype_arrow && tempitem.power>4)
7642 {
7643 tempitem.flags|=ITEM_FLAG1;
7644 }
7645 }
7646
7647
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(s_version < 18) // New Year's Eve 2007
7648 {
7649 if(tempitem.family == itype_whistle)
7650 tempitem.misc2 = 8; // Use the Whistle warp ring
7651 else if(tempitem.family == itype_bait)
7652 tempitem.misc1 = 768; // Frames until it goes
7653 else if(tempitem.family == itype_triforcepiece)
7654 {
7655 if(tempitem.flags & ITEM_GAMEDATA)
7656 {
7657 tempitem.misc2 = 1; // Cutscene 1
7658 tempitem.flags |= ITEM_FLAG1; // Side Warp Out
7659 }
7660 }
7661 }
7662
7663
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(s_version < 19) // January 2008
7664 {
7665 if(tempitem.family == itype_nayruslove)
7666 {
7667 tempitem.flags |= get_bit(deprecated_rules,qr_NOBOMBPALFLASH+1)?ITEM_FLAG3:0;
7668 tempitem.flags |= get_bit(deprecated_rules,qr_NOBOMBPALFLASH+2)?ITEM_FLAG4:0;
7669 }
7670 }
7671
7672
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(s_version < 20) // October 2008
7673 {
7674 if(tempitem.family == itype_nayruslove)
7675 {
7676 tempitem.wpn6=wNAYRUSLOVE2A;
7677 tempitem.wpn7=wNAYRUSLOVE2B;
7678 tempitem.wpn8=wNAYRUSLOVES2A;
7679 tempitem.wpn9=wNAYRUSLOVES2B;
7680 tempitem.wpn5 = iwNayrusLoveShieldFront;
7681 tempitem.wpn10 = iwNayrusLoveShieldBack;
7682 }
7683 }
7684
7685
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(s_version < 21) // November 2008
7686 {
7687 if(tempitem.flags & 0x0100) // ITEM_SLASH
7688 {
7689 tempitem.flags &= ~0x0100;
7690
7691 if(tempitem.family == itype_sword ||
7692 tempitem.family == itype_wand ||
7693 tempitem.family == itype_candle ||
7694 tempitem.family == itype_cbyrna)
7695 {
7696 tempitem.flags |= ITEM_FLAG4;
7697 }
7698 }
7699 }
7700
7701
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(s_version < 22) // September 2009
7702 {
7703 if(tempitem.family == itype_sbomb || tempitem.family == itype_bomb)
7704 {
7705 tempitem.misc3 = tempitem.power/2;
7706 }
7707 }
7708
7709
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(s_version < 23) // March 2011
7710 {
7711 if(tempitem.family == itype_dinsfire)
7712 tempitem.wpn5 = wFIRE;
7713 else if(tempitem.family == itype_book)
7714 tempitem.wpn2 = wFIRE;
7715 }
7716
7717 // Version 25: Bomb bags were acting as though "super bombs also" was checked
7718 // whether it was or not, and a lot of existing quests depended on the
7719 // incorrect behavior.
7720
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(s_version < 25) // January 2012
7721 {
7722 if(tempitem.family == itype_bombbag)
7723 tempitem.flags |= 16;
7724
7725 if(tempitem.family == itype_dinsfire)
7726 tempitem.flags |= ITEM_FLAG3; // Sideview gravity flag
7727 }
7728
7729
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 14080 times.
14848 if( version < 0x254) //Nuke greyed-out flags/values from <=2.53, in case they are used in 2.54/2.55
7730 {
7731
60/60
✓ Branch 0 taken 807 times.
✓ Branch 1 taken 596 times.
✓ Branch 2 taken 165 times.
✓ Branch 3 taken 717 times.
✓ Branch 4 taken 1625 times.
✓ Branch 5 taken 5124 times.
✓ Branch 6 taken 165 times.
✓ Branch 7 taken 165 times.
✓ Branch 8 taken 143 times.
✓ Branch 9 taken 101 times.
✓ Branch 10 taken 55 times.
✓ Branch 11 taken 110 times.
✓ Branch 12 taken 110 times.
✓ Branch 13 taken 65 times.
✓ Branch 14 taken 165 times.
✓ Branch 15 taken 165 times.
✓ Branch 16 taken 110 times.
✓ Branch 17 taken 165 times.
✓ Branch 18 taken 110 times.
✓ Branch 19 taken 55 times.
✓ Branch 20 taken 110 times.
✓ Branch 21 taken 65 times.
✓ Branch 22 taken 55 times.
✓ Branch 23 taken 165 times.
✓ Branch 24 taken 55 times.
✓ Branch 25 taken 55 times.
✓ Branch 26 taken 110 times.
✓ Branch 27 taken 55 times.
✓ Branch 28 taken 55 times.
✓ Branch 29 taken 55 times.
✓ Branch 30 taken 55 times.
✓ Branch 31 taken 55 times.
✓ Branch 32 taken 65 times.
✓ Branch 33 taken 55 times.
✓ Branch 34 taken 55 times.
✓ Branch 35 taken 55 times.
✓ Branch 36 taken 55 times.
✓ Branch 37 taken 110 times.
✓ Branch 38 taken 220 times.
✓ Branch 39 taken 55 times.
✓ Branch 40 taken 55 times.
✓ Branch 41 taken 97 times.
✓ Branch 42 taken 220 times.
✓ Branch 43 taken 55 times.
✓ Branch 44 taken 55 times.
✓ Branch 45 taken 55 times.
✓ Branch 46 taken 55 times.
✓ Branch 47 taken 55 times.
✓ Branch 48 taken 110 times.
✓ Branch 49 taken 110 times.
✓ Branch 50 taken 55 times.
✓ Branch 51 taken 165 times.
✓ Branch 52 taken 165 times.
✓ Branch 53 taken 220 times.
✓ Branch 54 taken 55 times.
✓ Branch 55 taken 55 times.
✓ Branch 56 taken 55 times.
✓ Branch 57 taken 55 times.
✓ Branch 58 taken 55 times.
✓ Branch 59 taken 55 times.
14080 switch(tempitem.family)
7732 {
7733 case itype_sword:
7734 {
7735 5124 tempitem.flags &= ~(ITEM_FLAG5);
7736 5124 tempitem.misc3 = 0;
7737 5124 tempitem.misc4 = 0;
7738 5124 tempitem.misc5 = 0;
7739 5124 tempitem.misc6 = 0;
7740 5124 tempitem.misc7 = 0;
7741 5124 tempitem.misc8 = 0;
7742 5124 tempitem.misc9 = 0;
7743 5124 tempitem.misc10 = 0;
7744 5124 tempitem.wpn4 = 0;
7745 5124 tempitem.wpn5 = 0;
7746 5124 tempitem.wpn6 = 0;
7747 5124 tempitem.wpn7 = 0;
7748 5124 tempitem.wpn8 = 0;
7749 5124 tempitem.wpn9 = 0;
7750 5124 tempitem.wpn10 = 0;
7751 5124 break;
7752 }
7753 case itype_brang:
7754 {
7755 165 tempitem.flags &= ~(ITEM_FLAG4 | ITEM_FLAG5);
7756 165 tempitem.misc2 = 0;
7757 165 tempitem.misc5 = 0;
7758 165 tempitem.misc6 = 0;
7759 165 tempitem.misc7 = 0;
7760 165 tempitem.misc8 = 0;
7761 165 tempitem.misc9 = 0;
7762 165 tempitem.misc10 = 0;
7763 165 tempitem.wpn4 = 0;
7764 165 tempitem.wpn5 = 0;
7765 165 tempitem.wpn6 = 0;
7766 165 tempitem.wpn7 = 0;
7767 165 tempitem.wpn8 = 0;
7768 165 tempitem.wpn9 = 0;
7769 165 tempitem.wpn10 = 0;
7770 165 break;
7771 }
7772 case itype_arrow:
7773 {
7774 165 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7775 165 tempitem.misc2 = 0;
7776 165 tempitem.misc3 = 0;
7777 165 tempitem.misc4 = 0;
7778 165 tempitem.misc5 = 0;
7779 165 tempitem.misc6 = 0;
7780 165 tempitem.misc7 = 0;
7781 165 tempitem.misc8 = 0;
7782 165 tempitem.misc9 = 0;
7783 165 tempitem.misc10 = 0;
7784 165 tempitem.wpn4 = 0;
7785 165 tempitem.wpn5 = 0;
7786 165 tempitem.wpn6 = 0;
7787 165 tempitem.wpn7 = 0;
7788 165 tempitem.wpn8 = 0;
7789 165 tempitem.wpn9 = 0;
7790 165 tempitem.wpn10 = 0;
7791 165 break;
7792 }
7793 case itype_candle:
7794 {
7795 143 tempitem.flags &= ~ (ITEM_FLAG3 | ITEM_FLAG5);
7796 143 tempitem.misc1 = 0;
7797 143 tempitem.misc2 = 0;
7798 143 tempitem.misc3 = 0;
7799 143 tempitem.misc4 = 0;
7800 143 tempitem.misc5 = 0;
7801 143 tempitem.misc6 = 0;
7802 143 tempitem.misc7 = 0;
7803 143 tempitem.misc8 = 0;
7804 143 tempitem.misc9 = 0;
7805 143 tempitem.misc10 = 0;
7806 143 tempitem.wpn4 = 0;
7807 143 tempitem.wpn5 = 0;
7808 143 tempitem.wpn6 = 0;
7809 143 tempitem.wpn7 = 0;
7810 143 tempitem.wpn8 = 0;
7811 143 tempitem.wpn9 = 0;
7812 143 tempitem.wpn10 = 0;
7813 143 break;
7814 }
7815 case itype_whistle:
7816 {
7817 101 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7818 101 tempitem.misc3 = 0;
7819 101 tempitem.misc4 = 0;
7820 101 tempitem.misc5 = 0;
7821 101 tempitem.misc6 = 0;
7822 101 tempitem.misc7 = 0;
7823 101 tempitem.misc8 = 0;
7824 101 tempitem.misc9 = 0;
7825 101 tempitem.misc10 = 0;
7826 101 tempitem.wpn2 = 0;
7827 101 tempitem.wpn3 = 0;
7828 101 tempitem.wpn4 = 0;
7829 101 tempitem.wpn5 = 0;
7830 101 tempitem.wpn6 = 0;
7831 101 tempitem.wpn7 = 0;
7832 101 tempitem.wpn8 = 0;
7833 101 tempitem.wpn9 = 0;
7834 101 tempitem.wpn10 = 0;
7835 101 break;
7836 }
7837 case itype_bait:
7838 {
7839 55 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7840 55 tempitem.misc2 = 0;
7841 55 tempitem.misc3 = 0;
7842 55 tempitem.misc4 = 0;
7843 55 tempitem.misc5 = 0;
7844 55 tempitem.misc6 = 0;
7845 55 tempitem.misc7 = 0;
7846 55 tempitem.misc8 = 0;
7847 55 tempitem.misc9 = 0;
7848 55 tempitem.misc10 = 0;
7849 55 tempitem.wpn2 = 0;
7850 55 tempitem.wpn3 = 0;
7851 55 tempitem.wpn4 = 0;
7852 55 tempitem.wpn5 = 0;
7853 55 tempitem.wpn6 = 0;
7854 55 tempitem.wpn7 = 0;
7855 55 tempitem.wpn8 = 0;
7856 55 tempitem.wpn9 = 0;
7857 55 tempitem.wpn10 = 0;
7858 55 break;
7859 }
7860 case itype_letter:
7861 {
7862 110 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7863 110 tempitem.misc1 = 0;
7864 110 tempitem.misc2 = 0;
7865 110 tempitem.misc3 = 0;
7866 110 tempitem.misc4 = 0;
7867 110 tempitem.misc5 = 0;
7868 110 tempitem.misc6 = 0;
7869 110 tempitem.misc7 = 0;
7870 110 tempitem.misc8 = 0;
7871 110 tempitem.misc9 = 0;
7872 110 tempitem.misc10 = 0;
7873 110 tempitem.wpn = 0;
7874 110 tempitem.wpn2 = 0;
7875 110 tempitem.wpn3 = 0;
7876 110 tempitem.wpn4 = 0;
7877 110 tempitem.wpn5 = 0;
7878 110 tempitem.wpn6 = 0;
7879 110 tempitem.wpn7 = 0;
7880 110 tempitem.wpn8 = 0;
7881 110 tempitem.wpn9 = 0;
7882 110 tempitem.wpn10 = 0;
7883 110 break;
7884 }
7885 case itype_potion:
7886 {
7887 110 tempitem.flags &= ~ (ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7888 110 tempitem.misc3 = 0;
7889 110 tempitem.misc4 = 0;
7890 110 tempitem.misc5 = 0;
7891 110 tempitem.misc6 = 0;
7892 110 tempitem.misc7 = 0;
7893 110 tempitem.misc8 = 0;
7894 110 tempitem.misc9 = 0;
7895 110 tempitem.misc10 = 0;
7896 110 tempitem.wpn = 0;
7897 110 tempitem.wpn2 = 0;
7898 110 tempitem.wpn3 = 0;
7899 110 tempitem.wpn4 = 0;
7900 110 tempitem.wpn5 = 0;
7901 110 tempitem.wpn6 = 0;
7902 110 tempitem.wpn7 = 0;
7903 110 tempitem.wpn8 = 0;
7904 110 tempitem.wpn9 = 0;
7905 110 tempitem.wpn10 = 0;
7906 110 break;
7907 }
7908 case itype_wand:
7909 {
7910 65 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG5);
7911 65 tempitem.misc1 = 0;
7912 65 tempitem.misc2 = 0;
7913 65 tempitem.misc3 = 0;
7914 65 tempitem.misc4 = 0;
7915 65 tempitem.misc5 = 0;
7916 65 tempitem.misc6 = 0;
7917 65 tempitem.misc7 = 0;
7918 65 tempitem.misc8 = 0;
7919 65 tempitem.misc9 = 0;
7920 65 tempitem.misc10 = 0;
7921 65 tempitem.wpn4 = 0;
7922 65 tempitem.wpn5 = 0;
7923 65 tempitem.wpn6 = 0;
7924 65 tempitem.wpn7 = 0;
7925 65 tempitem.wpn8 = 0;
7926 65 tempitem.wpn9 = 0;
7927 65 tempitem.wpn10 = 0;
7928 65 break;
7929 }
7930 case itype_ring:
7931 {
7932 165 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7933 165 tempitem.misc2 = 0;
7934 165 tempitem.misc3 = 0;
7935 165 tempitem.misc4 = 0;
7936 165 tempitem.misc5 = 0;
7937 165 tempitem.misc6 = 0;
7938 165 tempitem.misc7 = 0;
7939 165 tempitem.misc8 = 0;
7940 165 tempitem.misc9 = 0;
7941 165 tempitem.misc10 = 0;
7942 165 tempitem.wpn = 0;
7943 165 tempitem.wpn2 = 0;
7944 165 tempitem.wpn3 = 0;
7945 165 tempitem.wpn4 = 0;
7946 165 tempitem.wpn5 = 0;
7947 165 tempitem.wpn6 = 0;
7948 165 tempitem.wpn7 = 0;
7949 165 tempitem.wpn8 = 0;
7950 165 tempitem.wpn9 = 0;
7951 165 tempitem.wpn10 = 0;
7952 165 break;
7953 }
7954 case itype_wallet:
7955 {
7956 165 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7957 165 tempitem.misc3 = 0;
7958 165 tempitem.misc4 = 0;
7959 165 tempitem.misc5 = 0;
7960 165 tempitem.misc6 = 0;
7961 165 tempitem.misc7 = 0;
7962 165 tempitem.misc8 = 0;
7963 165 tempitem.misc9 = 0;
7964 165 tempitem.misc10 = 0;
7965 165 tempitem.wpn = 0;
7966 165 tempitem.wpn2 = 0;
7967 165 tempitem.wpn3 = 0;
7968 165 tempitem.wpn4 = 0;
7969 165 tempitem.wpn5 = 0;
7970 165 tempitem.wpn6 = 0;
7971 165 tempitem.wpn7 = 0;
7972 165 tempitem.wpn8 = 0;
7973 165 tempitem.wpn9 = 0;
7974 165 tempitem.wpn10 = 0;
7975 165 break;
7976 }
7977 case itype_amulet:
7978 {
7979 110 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7980 110 tempitem.misc1 = 0;
7981 110 tempitem.misc2 = 0;
7982 110 tempitem.misc3 = 0;
7983 110 tempitem.misc4 = 0;
7984 110 tempitem.misc5 = 0;
7985 110 tempitem.misc6 = 0;
7986 110 tempitem.misc7 = 0;
7987 110 tempitem.misc8 = 0;
7988 110 tempitem.misc9 = 0;
7989 110 tempitem.misc10 = 0;
7990 110 tempitem.wpn = 0;
7991 110 tempitem.wpn2 = 0;
7992 110 tempitem.wpn3 = 0;
7993 110 tempitem.wpn4 = 0;
7994 110 tempitem.wpn5 = 0;
7995 110 tempitem.wpn6 = 0;
7996 110 tempitem.wpn7 = 0;
7997 110 tempitem.wpn8 = 0;
7998 110 tempitem.wpn9 = 0;
7999 110 tempitem.wpn10 = 0;
8000 110 break;
8001 }
8002 case itype_shield:
8003 {
8004 165 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8005 165 tempitem.misc3 = 0;
8006 165 tempitem.misc4 = 0;
8007 165 tempitem.misc5 = 0;
8008 165 tempitem.misc6 = 0;
8009 165 tempitem.misc7 = 0;
8010 165 tempitem.misc8 = 0;
8011 165 tempitem.misc9 = 0;
8012 165 tempitem.misc10 = 0;
8013 165 tempitem.wpn = 0;
8014 165 tempitem.wpn2 = 0;
8015 165 tempitem.wpn3 = 0;
8016 165 tempitem.wpn4 = 0;
8017 165 tempitem.wpn5 = 0;
8018 165 tempitem.wpn6 = 0;
8019 165 tempitem.wpn7 = 0;
8020 165 tempitem.wpn8 = 0;
8021 165 tempitem.wpn9 = 0;
8022 165 tempitem.wpn10 = 0;
8023 165 break;
8024 }
8025 case itype_bow:
8026 {
8027 110 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8028 110 tempitem.misc1 = 0;
8029 110 tempitem.misc2 = 0;
8030 110 tempitem.misc3 = 0;
8031 110 tempitem.misc4 = 0;
8032 110 tempitem.misc5 = 0;
8033 110 tempitem.misc6 = 0;
8034 110 tempitem.misc7 = 0;
8035 110 tempitem.misc8 = 0;
8036 110 tempitem.misc9 = 0;
8037 110 tempitem.misc10 = 0;
8038 110 tempitem.wpn = 0;
8039 110 tempitem.wpn2 = 0;
8040 110 tempitem.wpn3 = 0;
8041 110 tempitem.wpn4 = 0;
8042 110 tempitem.wpn5 = 0;
8043 110 tempitem.wpn6 = 0;
8044 110 tempitem.wpn7 = 0;
8045 110 tempitem.wpn8 = 0;
8046 110 tempitem.wpn9 = 0;
8047 110 tempitem.wpn10 = 0;
8048 110 break;
8049 }
8050 case itype_raft:
8051 {
8052 55 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8053 55 tempitem.misc1 = 0;
8054 55 tempitem.misc2 = 0;
8055 55 tempitem.misc3 = 0;
8056 55 tempitem.misc4 = 0;
8057 55 tempitem.misc5 = 0;
8058 55 tempitem.misc6 = 0;
8059 55 tempitem.misc7 = 0;
8060 55 tempitem.misc8 = 0;
8061 55 tempitem.misc9 = 0;
8062 55 tempitem.misc10 = 0;
8063 55 tempitem.wpn = 0;
8064 55 tempitem.wpn2 = 0;
8065 55 tempitem.wpn3 = 0;
8066 55 tempitem.wpn4 = 0;
8067 55 tempitem.wpn5 = 0;
8068 55 tempitem.wpn6 = 0;
8069 55 tempitem.wpn7 = 0;
8070 55 tempitem.wpn8 = 0;
8071 55 tempitem.wpn9 = 0;
8072 55 tempitem.wpn10 = 0;
8073 55 break;
8074 }
8075 case itype_ladder:
8076 {
8077 110 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8078 110 tempitem.misc1 = 0;
8079 110 tempitem.misc2 = 0;
8080 110 tempitem.misc3 = 0;
8081 110 tempitem.misc4 = 0;
8082 110 tempitem.misc5 = 0;
8083 110 tempitem.misc6 = 0;
8084 110 tempitem.misc7 = 0;
8085 110 tempitem.misc8 = 0;
8086 110 tempitem.misc9 = 0;
8087 110 tempitem.misc10 = 0;
8088 110 tempitem.wpn = 0;
8089 110 tempitem.wpn2 = 0;
8090 110 tempitem.wpn3 = 0;
8091 110 tempitem.wpn4 = 0;
8092 110 tempitem.wpn5 = 0;
8093 110 tempitem.wpn6 = 0;
8094 110 tempitem.wpn7 = 0;
8095 110 tempitem.wpn8 = 0;
8096 110 tempitem.wpn9 = 0;
8097 110 tempitem.wpn10 = 0;
8098 110 break;
8099 }
8100 case itype_book:
8101 {
8102 65 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8103 65 tempitem.misc1 = 0;
8104 65 tempitem.misc2 = 0;
8105 65 tempitem.misc3 = 0;
8106 65 tempitem.misc4 = 0;
8107 65 tempitem.misc5 = 0;
8108 65 tempitem.misc6 = 0;
8109 65 tempitem.misc7 = 0;
8110 65 tempitem.misc8 = 0;
8111 65 tempitem.misc9 = 0;
8112 65 tempitem.misc10 = 0;
8113 65 tempitem.wpn3 = 0;
8114 65 tempitem.wpn4 = 0;
8115 65 tempitem.wpn5 = 0;
8116 65 tempitem.wpn6 = 0;
8117 65 tempitem.wpn7 = 0;
8118 65 tempitem.wpn8 = 0;
8119 65 tempitem.wpn9 = 0;
8120 65 tempitem.wpn10 = 0;
8121 65 break;
8122 }
8123 case itype_magickey:
8124 {
8125 55 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8126 55 tempitem.misc1 = 0;
8127 55 tempitem.misc2 = 0;
8128 55 tempitem.misc3 = 0;
8129 55 tempitem.misc4 = 0;
8130 55 tempitem.misc5 = 0;
8131 55 tempitem.misc6 = 0;
8132 55 tempitem.misc7 = 0;
8133 55 tempitem.misc8 = 0;
8134 55 tempitem.misc9 = 0;
8135 55 tempitem.misc10 = 0;
8136 55 tempitem.wpn = 0;
8137 55 tempitem.wpn2 = 0;
8138 55 tempitem.wpn3 = 0;
8139 55 tempitem.wpn4 = 0;
8140 55 tempitem.wpn5 = 0;
8141 55 tempitem.wpn6 = 0;
8142 55 tempitem.wpn7 = 0;
8143 55 tempitem.wpn8 = 0;
8144 55 tempitem.wpn9 = 0;
8145 55 tempitem.wpn10 = 0;
8146 55 break;
8147 }
8148 case itype_bracelet:
8149 {
8150 165 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8151 165 tempitem.misc1 = 0;
8152 165 tempitem.misc2 = 0;
8153 165 tempitem.misc3 = 0;
8154 165 tempitem.misc4 = 0;
8155 165 tempitem.misc5 = 0;
8156 165 tempitem.misc6 = 0;
8157 165 tempitem.misc7 = 0;
8158 165 tempitem.misc8 = 0;
8159 165 tempitem.misc9 = 0;
8160 165 tempitem.misc10 = 0;
8161 165 tempitem.wpn = 0;
8162 165 tempitem.wpn2 = 0;
8163 165 tempitem.wpn3 = 0;
8164 165 tempitem.wpn4 = 0;
8165 165 tempitem.wpn5 = 0;
8166 165 tempitem.wpn6 = 0;
8167 165 tempitem.wpn7 = 0;
8168 165 tempitem.wpn8 = 0;
8169 165 tempitem.wpn9 = 0;
8170 165 tempitem.wpn10 = 0;
8171 165 break;
8172 }
8173 case itype_flippers:
8174 {
8175 55 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8176 55 tempitem.misc1 = 0;
8177 55 tempitem.misc2 = 0;
8178 55 tempitem.misc3 = 0;
8179 55 tempitem.misc4 = 0;
8180 55 tempitem.misc5 = 0;
8181 55 tempitem.misc6 = 0;
8182 55 tempitem.misc7 = 0;
8183 55 tempitem.misc8 = 0;
8184 55 tempitem.misc9 = 0;
8185 55 tempitem.misc10 = 0;
8186 55 tempitem.wpn = 0;
8187 55 tempitem.wpn2 = 0;
8188 55 tempitem.wpn3 = 0;
8189 55 tempitem.wpn4 = 0;
8190 55 tempitem.wpn5 = 0;
8191 55 tempitem.wpn6 = 0;
8192 55 tempitem.wpn7 = 0;
8193 55 tempitem.wpn8 = 0;
8194 55 tempitem.wpn9 = 0;
8195 55 tempitem.wpn10 = 0;
8196 55 break;
8197 }
8198 case itype_boots:
8199 {
8200 55 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8201 55 tempitem.misc1 = 0;
8202 55 tempitem.misc2 = 0;
8203 55 tempitem.misc3 = 0;
8204 55 tempitem.misc4 = 0;
8205 55 tempitem.misc5 = 0;
8206 55 tempitem.misc6 = 0;
8207 55 tempitem.misc7 = 0;
8208 55 tempitem.misc8 = 0;
8209 55 tempitem.misc9 = 0;
8210 55 tempitem.misc10 = 0;
8211 55 tempitem.wpn = 0;
8212 55 tempitem.wpn2 = 0;
8213 55 tempitem.wpn3 = 0;
8214 55 tempitem.wpn4 = 0;
8215 55 tempitem.wpn5 = 0;
8216 55 tempitem.wpn6 = 0;
8217 55 tempitem.wpn7 = 0;
8218 55 tempitem.wpn8 = 0;
8219 55 tempitem.wpn9 = 0;
8220 55 tempitem.wpn10 = 0;
8221 55 break;
8222 }
8223 case itype_hookshot:
8224 {
8225 110 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8226 110 tempitem.misc5 = 0;
8227 110 tempitem.misc6 = 0;
8228 110 tempitem.misc7 = 0;
8229 110 tempitem.misc8 = 0;
8230 110 tempitem.misc9 = 0;
8231 110 tempitem.misc10 = 0;
8232 110 tempitem.wpn5 = 0;
8233 110 tempitem.wpn6 = 0;
8234 110 tempitem.wpn7 = 0;
8235 110 tempitem.wpn8 = 0;
8236 110 tempitem.wpn9 = 0;
8237 110 tempitem.wpn10 = 0;
8238 110 break;
8239 }
8240 case itype_lens:
8241 {
8242 55 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8243 55 tempitem.misc2 = 0;
8244 55 tempitem.misc3 = 0;
8245 55 tempitem.misc4 = 0;
8246 55 tempitem.misc5 = 0;
8247 55 tempitem.misc6 = 0;
8248 55 tempitem.misc7 = 0;
8249 55 tempitem.misc8 = 0;
8250 55 tempitem.misc9 = 0;
8251 55 tempitem.misc10 = 0;
8252 55 tempitem.wpn = 0;
8253 55 tempitem.wpn2 = 0;
8254 55 tempitem.wpn3 = 0;
8255 55 tempitem.wpn4 = 0;
8256 55 tempitem.wpn5 = 0;
8257 55 tempitem.wpn6 = 0;
8258 55 tempitem.wpn7 = 0;
8259 55 tempitem.wpn8 = 0;
8260 55 tempitem.wpn9 = 0;
8261 55 tempitem.wpn10 = 0;
8262 55 break;
8263 }
8264 case itype_hammer:
8265 {
8266 55 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8267 55 tempitem.misc1 = 0;
8268 55 tempitem.misc2 = 0;
8269 55 tempitem.misc3 = 0;
8270 55 tempitem.misc4 = 0;
8271 55 tempitem.misc5 = 0;
8272 55 tempitem.misc6 = 0;
8273 55 tempitem.misc7 = 0;
8274 55 tempitem.misc8 = 0;
8275 55 tempitem.misc9 = 0;
8276 55 tempitem.misc10 = 0;
8277 55 tempitem.wpn3 = 0;
8278 55 tempitem.wpn4 = 0;
8279 55 tempitem.wpn5 = 0;
8280 55 tempitem.wpn6 = 0;
8281 55 tempitem.wpn7 = 0;
8282 55 tempitem.wpn8 = 0;
8283 55 tempitem.wpn9 = 0;
8284 55 tempitem.wpn10 = 0;
8285 55 break;
8286 }
8287 case itype_dinsfire:
8288 {
8289 55 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG4 | ITEM_FLAG5);
8290 55 tempitem.misc3 = 0;
8291 55 tempitem.misc4 = 0;
8292 55 tempitem.misc5 = 0;
8293 55 tempitem.misc6 = 0;
8294 55 tempitem.misc7 = 0;
8295 55 tempitem.misc8 = 0;
8296 55 tempitem.misc9 = 0;
8297 55 tempitem.misc10 = 0;
8298 55 tempitem.wpn6 = 0;
8299 55 tempitem.wpn7 = 0;
8300 55 tempitem.wpn8 = 0;
8301 55 tempitem.wpn9 = 0;
8302 55 tempitem.wpn10 = 0;
8303 55 break;
8304 }
8305 case itype_faroreswind:
8306 {
8307 55 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8308 55 tempitem.misc2 = 0;
8309 55 tempitem.misc3 = 0;
8310 55 tempitem.misc4 = 0;
8311 55 tempitem.misc5 = 0;
8312 55 tempitem.misc6 = 0;
8313 55 tempitem.misc7 = 0;
8314 55 tempitem.misc8 = 0;
8315 55 tempitem.misc9 = 0;
8316 55 tempitem.misc10 = 0;
8317 55 tempitem.wpn = 0;
8318 55 tempitem.wpn2 = 0;
8319 55 tempitem.wpn3 = 0;
8320 55 tempitem.wpn4 = 0;
8321 55 tempitem.wpn5 = 0;
8322 55 tempitem.wpn6 = 0;
8323 55 tempitem.wpn7 = 0;
8324 55 tempitem.wpn8 = 0;
8325 55 tempitem.wpn9 = 0;
8326 55 tempitem.wpn10 = 0;
8327 55 break;
8328 }
8329 case itype_nayruslove:
8330 {
8331 55 tempitem.flags &= ~ (ITEM_FLAG5);
8332 55 tempitem.misc2 = 0;
8333 55 tempitem.misc3 = 0;
8334 55 tempitem.misc4 = 0;
8335 55 tempitem.misc5 = 0;
8336 55 tempitem.misc6 = 0;
8337 55 tempitem.misc7 = 0;
8338 55 tempitem.misc8 = 0;
8339 55 tempitem.misc9 = 0;
8340 55 tempitem.misc10 = 0;
8341 55 break;
8342 }
8343 case itype_bomb:
8344 {
8345 65 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8346 65 tempitem.misc4 = 0;
8347 65 tempitem.misc5 = 0;
8348 65 tempitem.misc6 = 0;
8349 65 tempitem.misc7 = 0;
8350 65 tempitem.misc8 = 0;
8351 65 tempitem.misc9 = 0;
8352 65 tempitem.misc10 = 0;
8353 65 tempitem.wpn3 = 0;
8354 65 tempitem.wpn4 = 0;
8355 65 tempitem.wpn5 = 0;
8356 65 tempitem.wpn6 = 0;
8357 65 tempitem.wpn7 = 0;
8358 65 tempitem.wpn8 = 0;
8359 65 tempitem.wpn9 = 0;
8360 65 tempitem.wpn10 = 0;
8361 65 break;
8362 }
8363 case itype_sbomb:
8364 {
8365 55 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8366 55 tempitem.misc4 = 0;
8367 55 tempitem.misc5 = 0;
8368 55 tempitem.misc6 = 0;
8369 55 tempitem.misc7 = 0;
8370 55 tempitem.misc8 = 0;
8371 55 tempitem.misc9 = 0;
8372 55 tempitem.misc10 = 0;
8373 55 tempitem.wpn3 = 0;
8374 55 tempitem.wpn4 = 0;
8375 55 tempitem.wpn5 = 0;
8376 55 tempitem.wpn6 = 0;
8377 55 tempitem.wpn7 = 0;
8378 55 tempitem.wpn8 = 0;
8379 55 tempitem.wpn9 = 0;
8380 55 tempitem.wpn10 = 0;
8381 55 break;
8382 }
8383 case itype_clock:
8384 {
8385 55 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8386 55 tempitem.misc2 = 0;
8387 55 tempitem.misc3 = 0;
8388 55 tempitem.misc4 = 0;
8389 55 tempitem.misc5 = 0;
8390 55 tempitem.misc6 = 0;
8391 55 tempitem.misc7 = 0;
8392 55 tempitem.misc8 = 0;
8393 55 tempitem.misc9 = 0;
8394 55 tempitem.misc10 = 0;
8395 55 tempitem.wpn = 0;
8396 55 tempitem.wpn2 = 0;
8397 55 tempitem.wpn3 = 0;
8398 55 tempitem.wpn4 = 0;
8399 55 tempitem.wpn5 = 0;
8400 55 tempitem.wpn6 = 0;
8401 55 tempitem.wpn7 = 0;
8402 55 tempitem.wpn8 = 0;
8403 55 tempitem.wpn9 = 0;
8404 55 tempitem.wpn10 = 0;
8405 55 break;
8406 }
8407 case itype_key:
8408 {
8409 55 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8410 55 tempitem.misc1 = 0;
8411 55 tempitem.misc2 = 0;
8412 55 tempitem.misc3 = 0;
8413 55 tempitem.misc4 = 0;
8414 55 tempitem.misc5 = 0;
8415 55 tempitem.misc6 = 0;
8416 55 tempitem.misc7 = 0;
8417 55 tempitem.misc8 = 0;
8418 55 tempitem.misc9 = 0;
8419 55 tempitem.misc10 = 0;
8420 55 tempitem.wpn = 0;
8421 55 tempitem.wpn2 = 0;
8422 55 tempitem.wpn3 = 0;
8423 55 tempitem.wpn4 = 0;
8424 55 tempitem.wpn5 = 0;
8425 55 tempitem.wpn6 = 0;
8426 55 tempitem.wpn7 = 0;
8427 55 tempitem.wpn8 = 0;
8428 55 tempitem.wpn9 = 0;
8429 55 tempitem.wpn10 = 0;
8430 55 break;
8431 }
8432 case itype_magiccontainer:
8433 {
8434 55 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8435 55 tempitem.misc1 = 0;
8436 55 tempitem.misc2 = 0;
8437 55 tempitem.misc3 = 0;
8438 55 tempitem.misc4 = 0;
8439 55 tempitem.misc5 = 0;
8440 55 tempitem.misc6 = 0;
8441 55 tempitem.misc7 = 0;
8442 55 tempitem.misc8 = 0;
8443 55 tempitem.misc9 = 0;
8444 55 tempitem.misc10 = 0;
8445 55 tempitem.wpn = 0;
8446 55 tempitem.wpn2 = 0;
8447 55 tempitem.wpn3 = 0;
8448 55 tempitem.wpn4 = 0;
8449 55 tempitem.wpn5 = 0;
8450 55 tempitem.wpn6 = 0;
8451 55 tempitem.wpn7 = 0;
8452 55 tempitem.wpn8 = 0;
8453 55 tempitem.wpn9 = 0;
8454 55 tempitem.wpn10 = 0;
8455 55 break;
8456 }
8457 case itype_triforcepiece:
8458 {
8459 110 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8460 110 tempitem.misc3 = 0;
8461 110 tempitem.misc4 = 0;
8462 110 tempitem.misc5 = 0;
8463 110 tempitem.misc6 = 0;
8464 110 tempitem.misc7 = 0;
8465 110 tempitem.misc8 = 0;
8466 110 tempitem.misc9 = 0;
8467 110 tempitem.misc10 = 0;
8468 110 tempitem.wpn = 0;
8469 110 tempitem.wpn2 = 0;
8470 110 tempitem.wpn3 = 0;
8471 110 tempitem.wpn4 = 0;
8472 110 tempitem.wpn5 = 0;
8473 110 tempitem.wpn6 = 0;
8474 110 tempitem.wpn7 = 0;
8475 110 tempitem.wpn8 = 0;
8476 110 tempitem.wpn9 = 0;
8477 110 tempitem.wpn10 = 0;
8478 110 break;
8479 }
8480 case itype_map: case itype_compass: case itype_bosskey:
8481 {
8482 165 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8483 165 tempitem.misc1 = 0;
8484 165 tempitem.misc2 = 0;
8485 165 tempitem.misc3 = 0;
8486 165 tempitem.misc4 = 0;
8487 165 tempitem.misc5 = 0;
8488 165 tempitem.misc6 = 0;
8489 165 tempitem.misc7 = 0;
8490 165 tempitem.misc8 = 0;
8491 165 tempitem.misc9 = 0;
8492 165 tempitem.misc10 = 0;
8493 165 tempitem.wpn = 0;
8494 165 tempitem.wpn2 = 0;
8495 165 tempitem.wpn3 = 0;
8496 165 tempitem.wpn4 = 0;
8497 165 tempitem.wpn5 = 0;
8498 165 tempitem.wpn6 = 0;
8499 165 tempitem.wpn7 = 0;
8500 165 tempitem.wpn8 = 0;
8501 165 tempitem.wpn9 = 0;
8502 165 tempitem.wpn10 = 0;
8503 165 break;
8504 }
8505 case itype_quiver:
8506 {
8507 220 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8508 220 tempitem.misc3 = 0;
8509 220 tempitem.misc4 = 0;
8510 220 tempitem.misc5 = 0;
8511 220 tempitem.misc6 = 0;
8512 220 tempitem.misc7 = 0;
8513 220 tempitem.misc8 = 0;
8514 220 tempitem.misc9 = 0;
8515 220 tempitem.misc10 = 0;
8516 220 tempitem.wpn = 0;
8517 220 tempitem.wpn2 = 0;
8518 220 tempitem.wpn3 = 0;
8519 220 tempitem.wpn4 = 0;
8520 220 tempitem.wpn5 = 0;
8521 220 tempitem.wpn6 = 0;
8522 220 tempitem.wpn7 = 0;
8523 220 tempitem.wpn8 = 0;
8524 220 tempitem.wpn9 = 0;
8525 220 tempitem.wpn10 = 0;
8526 220 break;
8527 }
8528 case itype_lkey:
8529 {
8530 55 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8531 55 tempitem.misc1 = 0;
8532 55 tempitem.misc2 = 0;
8533 55 tempitem.misc3 = 0;
8534 55 tempitem.misc4 = 0;
8535 55 tempitem.misc5 = 0;
8536 55 tempitem.misc6 = 0;
8537 55 tempitem.misc7 = 0;
8538 55 tempitem.misc8 = 0;
8539 55 tempitem.misc9 = 0;
8540 55 tempitem.misc10 = 0;
8541 55 tempitem.wpn = 0;
8542 55 tempitem.wpn2 = 0;
8543 55 tempitem.wpn3 = 0;
8544 55 tempitem.wpn4 = 0;
8545 55 tempitem.wpn5 = 0;
8546 55 tempitem.wpn6 = 0;
8547 55 tempitem.wpn7 = 0;
8548 55 tempitem.wpn8 = 0;
8549 55 tempitem.wpn9 = 0;
8550 55 tempitem.wpn10 = 0;
8551 55 break;
8552 }
8553 case itype_cbyrna:
8554 {
8555 55 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG5);
8556 55 tempitem.misc4 = 0;
8557 55 tempitem.misc5 = 0;
8558 55 tempitem.misc6 = 0;
8559 55 tempitem.misc7 = 0;
8560 55 tempitem.misc8 = 0;
8561 55 tempitem.misc9 = 0;
8562 55 tempitem.misc10 = 0;
8563 55 tempitem.wpn6 = 0;
8564 55 tempitem.wpn7 = 0;
8565 55 tempitem.wpn8 = 0;
8566 55 tempitem.wpn9 = 0;
8567 55 tempitem.wpn10 = 0;
8568 55 break;
8569 }
8570 case itype_rupee: case itype_arrowammo:
8571 {
8572 717 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8573 717 tempitem.misc1 = 0;
8574 717 tempitem.misc2 = 0;
8575 717 tempitem.misc3 = 0;
8576 717 tempitem.misc4 = 0;
8577 717 tempitem.misc5 = 0;
8578 717 tempitem.misc6 = 0;
8579 717 tempitem.misc7 = 0;
8580 717 tempitem.misc8 = 0;
8581 717 tempitem.misc9 = 0;
8582 717 tempitem.misc10 = 0;
8583 717 tempitem.wpn = 0;
8584 717 tempitem.wpn2 = 0;
8585 717 tempitem.wpn3 = 0;
8586 717 tempitem.wpn4 = 0;
8587 717 tempitem.wpn5 = 0;
8588 717 tempitem.wpn6 = 0;
8589 717 tempitem.wpn7 = 0;
8590 717 tempitem.wpn8 = 0;
8591 717 tempitem.wpn9 = 0;
8592 717 tempitem.wpn10 = 0;
8593 717 break;
8594 }
8595 case itype_fairy:
8596 {
8597 97 tempitem.flags &= ~ (ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8598 97 tempitem.misc4 = 0;
8599 97 tempitem.misc5 = 0;
8600 97 tempitem.misc6 = 0;
8601 97 tempitem.misc7 = 0;
8602 97 tempitem.misc8 = 0;
8603 97 tempitem.misc9 = 0;
8604 97 tempitem.misc10 = 0;
8605 97 tempitem.wpn = 0;
8606 97 tempitem.wpn2 = 0;
8607 97 tempitem.wpn3 = 0;
8608 97 tempitem.wpn4 = 0;
8609 97 tempitem.wpn5 = 0;
8610 97 tempitem.wpn6 = 0;
8611 97 tempitem.wpn7 = 0;
8612 97 tempitem.wpn8 = 0;
8613 97 tempitem.wpn9 = 0;
8614 97 tempitem.wpn10 = 0;
8615 97 break;
8616 }
8617 case itype_magic: case itype_heart: case itype_heartcontainer: case itype_heartpiece: case itype_killem: case itype_bombammo:
8618 {
8619 596 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8620 596 tempitem.misc1 = 0;
8621 596 tempitem.misc2 = 0;
8622 596 tempitem.misc3 = 0;
8623 596 tempitem.misc4 = 0;
8624 596 tempitem.misc5 = 0;
8625 596 tempitem.misc6 = 0;
8626 596 tempitem.misc7 = 0;
8627 596 tempitem.misc8 = 0;
8628 596 tempitem.misc9 = 0;
8629 596 tempitem.misc10 = 0;
8630 596 tempitem.wpn = 0;
8631 596 tempitem.wpn2 = 0;
8632 596 tempitem.wpn3 = 0;
8633 596 tempitem.wpn4 = 0;
8634 596 tempitem.wpn5 = 0;
8635 596 tempitem.wpn6 = 0;
8636 596 tempitem.wpn7 = 0;
8637 596 tempitem.wpn8 = 0;
8638 596 tempitem.wpn9 = 0;
8639 596 tempitem.wpn10 = 0;
8640 596 break;
8641 }
8642 case itype_bombbag:
8643 {
8644 220 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8645 220 tempitem.misc3 = 0;
8646 220 tempitem.misc4 = 0;
8647 220 tempitem.misc5 = 0;
8648 220 tempitem.misc6 = 0;
8649 220 tempitem.misc7 = 0;
8650 220 tempitem.misc8 = 0;
8651 220 tempitem.misc9 = 0;
8652 220 tempitem.misc10 = 0;
8653 220 tempitem.wpn = 0;
8654 220 tempitem.wpn2 = 0;
8655 220 tempitem.wpn3 = 0;
8656 220 tempitem.wpn4 = 0;
8657 220 tempitem.wpn5 = 0;
8658 220 tempitem.wpn6 = 0;
8659 220 tempitem.wpn7 = 0;
8660 220 tempitem.wpn8 = 0;
8661 220 tempitem.wpn9 = 0;
8662 220 tempitem.wpn10 = 0;
8663 220 break;
8664 }
8665 case itype_rocs:
8666 {
8667 55 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8668 55 tempitem.misc1 = 0;
8669 55 tempitem.misc2 = 0;
8670 55 tempitem.misc3 = 0;
8671 55 tempitem.misc4 = 0;
8672 55 tempitem.misc5 = 0;
8673 55 tempitem.misc6 = 0;
8674 55 tempitem.misc7 = 0;
8675 55 tempitem.misc8 = 0;
8676 55 tempitem.misc9 = 0;
8677 55 tempitem.misc10 = 0;
8678 55 tempitem.wpn = 0;
8679 55 tempitem.wpn2 = 0;
8680 55 tempitem.wpn3 = 0;
8681 55 tempitem.wpn4 = 0;
8682 55 tempitem.wpn5 = 0;
8683 55 tempitem.wpn6 = 0;
8684 55 tempitem.wpn7 = 0;
8685 55 tempitem.wpn8 = 0;
8686 55 tempitem.wpn9 = 0;
8687 55 tempitem.wpn10 = 0;
8688 55 break;
8689 }
8690 case itype_hoverboots:
8691 {
8692 55 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8693 55 tempitem.misc2 = 0;
8694 55 tempitem.misc3 = 0;
8695 55 tempitem.misc4 = 0;
8696 55 tempitem.misc5 = 0;
8697 55 tempitem.misc6 = 0;
8698 55 tempitem.misc7 = 0;
8699 55 tempitem.misc8 = 0;
8700 55 tempitem.misc9 = 0;
8701 55 tempitem.misc10 = 0;
8702 55 tempitem.wpn2 = 0;
8703 55 tempitem.wpn3 = 0;
8704 55 tempitem.wpn4 = 0;
8705 55 tempitem.wpn5 = 0;
8706 55 tempitem.wpn6 = 0;
8707 55 tempitem.wpn7 = 0;
8708 55 tempitem.wpn8 = 0;
8709 55 tempitem.wpn9 = 0;
8710 55 tempitem.wpn10 = 0;
8711 55 break;
8712 }
8713 case itype_spinscroll:
8714 {
8715 55 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8716 55 tempitem.misc2 = 0;
8717 55 tempitem.misc3 = 0;
8718 55 tempitem.misc4 = 0;
8719 55 tempitem.misc5 = 0;
8720 55 tempitem.misc6 = 0;
8721 55 tempitem.misc7 = 0;
8722 55 tempitem.misc8 = 0;
8723 55 tempitem.misc9 = 0;
8724 55 tempitem.misc10 = 0;
8725 55 tempitem.wpn = 0;
8726 55 tempitem.wpn2 = 0;
8727 55 tempitem.wpn3 = 0;
8728 55 tempitem.wpn4 = 0;
8729 55 tempitem.wpn5 = 0;
8730 55 tempitem.wpn6 = 0;
8731 55 tempitem.wpn7 = 0;
8732 55 tempitem.wpn8 = 0;
8733 55 tempitem.wpn9 = 0;
8734 55 tempitem.wpn10 = 0;
8735 55 break;
8736 }
8737 case itype_crossscroll:
8738 {
8739 55 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8740 55 tempitem.misc1 = 0;
8741 55 tempitem.misc2 = 0;
8742 55 tempitem.misc3 = 0;
8743 55 tempitem.misc4 = 0;
8744 55 tempitem.misc5 = 0;
8745 55 tempitem.misc6 = 0;
8746 55 tempitem.misc7 = 0;
8747 55 tempitem.misc8 = 0;
8748 55 tempitem.misc9 = 0;
8749 55 tempitem.misc10 = 0;
8750 55 tempitem.wpn = 0;
8751 55 tempitem.wpn2 = 0;
8752 55 tempitem.wpn3 = 0;
8753 55 tempitem.wpn4 = 0;
8754 55 tempitem.wpn5 = 0;
8755 55 tempitem.wpn6 = 0;
8756 55 tempitem.wpn7 = 0;
8757 55 tempitem.wpn8 = 0;
8758 55 tempitem.wpn9 = 0;
8759 55 tempitem.wpn10 = 0;
8760 55 break;
8761 }
8762 case itype_quakescroll:
8763 {
8764 55 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8765 55 tempitem.misc3 = 0;
8766 55 tempitem.misc4 = 0;
8767 55 tempitem.misc5 = 0;
8768 55 tempitem.misc6 = 0;
8769 55 tempitem.misc7 = 0;
8770 55 tempitem.misc8 = 0;
8771 55 tempitem.misc9 = 0;
8772 55 tempitem.misc10 = 0;
8773 55 tempitem.wpn = 0;
8774 55 tempitem.wpn2 = 0;
8775 55 tempitem.wpn3 = 0;
8776 55 tempitem.wpn4 = 0;
8777 55 tempitem.wpn5 = 0;
8778 55 tempitem.wpn6 = 0;
8779 55 tempitem.wpn7 = 0;
8780 55 tempitem.wpn8 = 0;
8781 55 tempitem.wpn9 = 0;
8782 55 tempitem.wpn10 = 0;
8783 55 break;
8784 }
8785 case itype_whispring:
8786 {
8787 110 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8788 110 tempitem.misc2 = 0;
8789 110 tempitem.misc3 = 0;
8790 110 tempitem.misc4 = 0;
8791 110 tempitem.misc5 = 0;
8792 110 tempitem.misc6 = 0;
8793 110 tempitem.misc7 = 0;
8794 110 tempitem.misc8 = 0;
8795 110 tempitem.misc9 = 0;
8796 110 tempitem.misc10 = 0;
8797 110 tempitem.wpn = 0;
8798 110 tempitem.wpn2 = 0;
8799 110 tempitem.wpn3 = 0;
8800 110 tempitem.wpn4 = 0;
8801 110 tempitem.wpn5 = 0;
8802 110 tempitem.wpn6 = 0;
8803 110 tempitem.wpn7 = 0;
8804 110 tempitem.wpn8 = 0;
8805 110 tempitem.wpn9 = 0;
8806 110 tempitem.wpn10 = 0;
8807 110 break;
8808 }
8809 case itype_chargering:
8810 {
8811 110 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8812 110 tempitem.misc3 = 0;
8813 110 tempitem.misc4 = 0;
8814 110 tempitem.misc5 = 0;
8815 110 tempitem.misc6 = 0;
8816 110 tempitem.misc7 = 0;
8817 110 tempitem.misc8 = 0;
8818 110 tempitem.misc9 = 0;
8819 110 tempitem.misc10 = 0;
8820 110 tempitem.wpn = 0;
8821 110 tempitem.wpn2 = 0;
8822 110 tempitem.wpn3 = 0;
8823 110 tempitem.wpn4 = 0;
8824 110 tempitem.wpn5 = 0;
8825 110 tempitem.wpn6 = 0;
8826 110 tempitem.wpn7 = 0;
8827 110 tempitem.wpn8 = 0;
8828 110 tempitem.wpn9 = 0;
8829 110 tempitem.wpn10 = 0;
8830 110 break;
8831 }
8832 case itype_perilscroll:
8833 {
8834 55 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8835 55 tempitem.misc2 = 0;
8836 55 tempitem.misc3 = 0;
8837 55 tempitem.misc4 = 0;
8838 55 tempitem.misc5 = 0;
8839 55 tempitem.misc6 = 0;
8840 55 tempitem.misc7 = 0;
8841 55 tempitem.misc8 = 0;
8842 55 tempitem.misc9 = 0;
8843 55 tempitem.misc10 = 0;
8844 55 tempitem.wpn = 0;
8845 55 tempitem.wpn2 = 0;
8846 55 tempitem.wpn3 = 0;
8847 55 tempitem.wpn4 = 0;
8848 55 tempitem.wpn5 = 0;
8849 55 tempitem.wpn6 = 0;
8850 55 tempitem.wpn7 = 0;
8851 55 tempitem.wpn8 = 0;
8852 55 tempitem.wpn9 = 0;
8853 55 tempitem.wpn10 = 0;
8854 55 break;
8855 }
8856 case itype_wealthmedal:
8857 {
8858 165 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8859 165 tempitem.misc2 = 0;
8860 165 tempitem.misc3 = 0;
8861 165 tempitem.misc4 = 0;
8862 165 tempitem.misc5 = 0;
8863 165 tempitem.misc6 = 0;
8864 165 tempitem.misc7 = 0;
8865 165 tempitem.misc8 = 0;
8866 165 tempitem.misc9 = 0;
8867 165 tempitem.misc10 = 0;
8868 165 tempitem.wpn = 0;
8869 165 tempitem.wpn2 = 0;
8870 165 tempitem.wpn3 = 0;
8871 165 tempitem.wpn4 = 0;
8872 165 tempitem.wpn5 = 0;
8873 165 tempitem.wpn6 = 0;
8874 165 tempitem.wpn7 = 0;
8875 165 tempitem.wpn8 = 0;
8876 165 tempitem.wpn9 = 0;
8877 165 tempitem.wpn10 = 0;
8878 165 break;
8879 }
8880 case itype_heartring:
8881 {
8882 165 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8883 165 tempitem.misc3 = 0;
8884 165 tempitem.misc4 = 0;
8885 165 tempitem.misc5 = 0;
8886 165 tempitem.misc6 = 0;
8887 165 tempitem.misc7 = 0;
8888 165 tempitem.misc8 = 0;
8889 165 tempitem.misc9 = 0;
8890 165 tempitem.misc10 = 0;
8891 165 tempitem.wpn = 0;
8892 165 tempitem.wpn2 = 0;
8893 165 tempitem.wpn3 = 0;
8894 165 tempitem.wpn4 = 0;
8895 165 tempitem.wpn5 = 0;
8896 165 tempitem.wpn6 = 0;
8897 165 tempitem.wpn7 = 0;
8898 165 tempitem.wpn8 = 0;
8899 165 tempitem.wpn9 = 0;
8900 165 tempitem.wpn10 = 0;
8901 165 break;
8902 }
8903 case itype_magicring:
8904 {
8905 220 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8906 220 tempitem.misc3 = 0;
8907 220 tempitem.misc4 = 0;
8908 220 tempitem.misc5 = 0;
8909 220 tempitem.misc6 = 0;
8910 220 tempitem.misc7 = 0;
8911 220 tempitem.misc8 = 0;
8912 220 tempitem.misc9 = 0;
8913 220 tempitem.misc10 = 0;
8914 220 tempitem.wpn = 0;
8915 220 tempitem.wpn2 = 0;
8916 220 tempitem.wpn3 = 0;
8917 220 tempitem.wpn4 = 0;
8918 220 tempitem.wpn5 = 0;
8919 220 tempitem.wpn6 = 0;
8920 220 tempitem.wpn7 = 0;
8921 220 tempitem.wpn8 = 0;
8922 220 tempitem.wpn9 = 0;
8923 220 tempitem.wpn10 = 0;
8924 220 break;
8925 }
8926 case itype_spinscroll2:
8927 {
8928 55 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8929 55 tempitem.misc2 = 0;
8930 55 tempitem.misc3 = 0;
8931 55 tempitem.misc4 = 0;
8932 55 tempitem.misc5 = 0;
8933 55 tempitem.misc6 = 0;
8934 55 tempitem.misc7 = 0;
8935 55 tempitem.misc8 = 0;
8936 55 tempitem.misc9 = 0;
8937 55 tempitem.misc10 = 0;
8938 55 tempitem.wpn = 0;
8939 55 tempitem.wpn2 = 0;
8940 55 tempitem.wpn3 = 0;
8941 55 tempitem.wpn4 = 0;
8942 55 tempitem.wpn5 = 0;
8943 55 tempitem.wpn6 = 0;
8944 55 tempitem.wpn7 = 0;
8945 55 tempitem.wpn8 = 0;
8946 55 tempitem.wpn9 = 0;
8947 55 tempitem.wpn10 = 0;
8948 55 break;
8949 }
8950 case itype_quakescroll2:
8951 {
8952 55 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8953 55 tempitem.misc3 = 0;
8954 55 tempitem.misc4 = 0;
8955 55 tempitem.misc5 = 0;
8956 55 tempitem.misc6 = 0;
8957 55 tempitem.misc7 = 0;
8958 55 tempitem.misc8 = 0;
8959 55 tempitem.misc9 = 0;
8960 55 tempitem.misc10 = 0;
8961 55 tempitem.wpn = 0;
8962 55 tempitem.wpn2 = 0;
8963 55 tempitem.wpn3 = 0;
8964 55 tempitem.wpn4 = 0;
8965 55 tempitem.wpn5 = 0;
8966 55 tempitem.wpn6 = 0;
8967 55 tempitem.wpn7 = 0;
8968 55 tempitem.wpn8 = 0;
8969 55 tempitem.wpn9 = 0;
8970 55 tempitem.wpn10 = 0;
8971 55 break;
8972 }
8973 case itype_agony:
8974 {
8975 55 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8976 55 tempitem.misc2 = 0;
8977 55 tempitem.misc3 = 0;
8978 55 tempitem.misc4 = 0;
8979 55 tempitem.misc5 = 0;
8980 55 tempitem.misc6 = 0;
8981 55 tempitem.misc7 = 0;
8982 55 tempitem.misc8 = 0;
8983 55 tempitem.misc9 = 0;
8984 55 tempitem.misc10 = 0;
8985 55 tempitem.wpn = 0;
8986 55 tempitem.wpn2 = 0;
8987 55 tempitem.wpn3 = 0;
8988 55 tempitem.wpn4 = 0;
8989 55 tempitem.wpn5 = 0;
8990 55 tempitem.wpn6 = 0;
8991 55 tempitem.wpn7 = 0;
8992 55 tempitem.wpn8 = 0;
8993 55 tempitem.wpn9 = 0;
8994 55 tempitem.wpn10 = 0;
8995 55 break;
8996 }
8997 case itype_stompboots:
8998 {
8999 55 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9000 55 tempitem.misc1 = 0;
9001 55 tempitem.misc2 = 0;
9002 55 tempitem.misc3 = 0;
9003 55 tempitem.misc4 = 0;
9004 55 tempitem.misc5 = 0;
9005 55 tempitem.misc6 = 0;
9006 55 tempitem.misc7 = 0;
9007 55 tempitem.misc8 = 0;
9008 55 tempitem.misc9 = 0;
9009 55 tempitem.misc10 = 0;
9010 55 tempitem.wpn = 0;
9011 55 tempitem.wpn2 = 0;
9012 55 tempitem.wpn3 = 0;
9013 55 tempitem.wpn4 = 0;
9014 55 tempitem.wpn5 = 0;
9015 55 tempitem.wpn6 = 0;
9016 55 tempitem.wpn7 = 0;
9017 55 tempitem.wpn8 = 0;
9018 55 tempitem.wpn9 = 0;
9019 55 tempitem.wpn10 = 0;
9020 55 break;
9021 }
9022 case itype_whimsicalring:
9023 {
9024 55 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9025 55 tempitem.misc2 = 0;
9026 55 tempitem.misc3 = 0;
9027 55 tempitem.misc4 = 0;
9028 55 tempitem.misc5 = 0;
9029 55 tempitem.misc6 = 0;
9030 55 tempitem.misc7 = 0;
9031 55 tempitem.misc8 = 0;
9032 55 tempitem.misc9 = 0;
9033 55 tempitem.misc10 = 0;
9034 55 tempitem.wpn = 0;
9035 55 tempitem.wpn2 = 0;
9036 55 tempitem.wpn3 = 0;
9037 55 tempitem.wpn4 = 0;
9038 55 tempitem.wpn5 = 0;
9039 55 tempitem.wpn6 = 0;
9040 55 tempitem.wpn7 = 0;
9041 55 tempitem.wpn8 = 0;
9042 55 tempitem.wpn9 = 0;
9043 55 tempitem.wpn10 = 0;
9044 55 break;
9045 }
9046 case itype_perilring:
9047 {
9048 55 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9049 55 tempitem.misc2 = 0;
9050 55 tempitem.misc3 = 0;
9051 55 tempitem.misc4 = 0;
9052 55 tempitem.misc5 = 0;
9053 55 tempitem.misc6 = 0;
9054 55 tempitem.misc7 = 0;
9055 55 tempitem.misc8 = 0;
9056 55 tempitem.misc9 = 0;
9057 55 tempitem.misc10 = 0;
9058 55 tempitem.wpn = 0;
9059 55 tempitem.wpn2 = 0;
9060 55 tempitem.wpn3 = 0;
9061 55 tempitem.wpn4 = 0;
9062 55 tempitem.wpn5 = 0;
9063 55 tempitem.wpn6 = 0;
9064 55 tempitem.wpn7 = 0;
9065 55 tempitem.wpn8 = 0;
9066 55 tempitem.wpn9 = 0;
9067 55 tempitem.wpn10 = 0;
9068 55 break;
9069 }
9070 case itype_custom1: case itype_custom2: case itype_custom3: case itype_custom4: case itype_custom5:
9071 case itype_custom6: case itype_custom7: case itype_custom8: case itype_custom9: case itype_custom10:
9072 case itype_custom11: case itype_custom12: case itype_custom13: case itype_custom14: case itype_custom15:
9073 case itype_custom16: case itype_custom17: case itype_custom18: case itype_custom19: case itype_custom20:
9074 case itype_bowandarrow: case itype_letterpotion: case itype_misc:
9075 {
9076 807 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9077 807 tempitem.misc1 = 0;
9078 807 tempitem.misc2 = 0;
9079 807 tempitem.misc3 = 0;
9080 807 tempitem.misc4 = 0;
9081 807 tempitem.misc5 = 0;
9082 807 tempitem.misc6 = 0;
9083 807 tempitem.misc7 = 0;
9084 807 tempitem.misc8 = 0;
9085 807 tempitem.misc9 = 0;
9086 807 tempitem.misc10 = 0;
9087 807 tempitem.wpn = 0;
9088 807 tempitem.wpn2 = 0;
9089 807 tempitem.wpn3 = 0;
9090 807 tempitem.wpn4 = 0;
9091 807 tempitem.wpn5 = 0;
9092 807 tempitem.wpn6 = 0;
9093 807 tempitem.wpn7 = 0;
9094 807 tempitem.wpn8 = 0;
9095 807 tempitem.wpn9 = 0;
9096 807 tempitem.wpn10 = 0;
9097 807 break;
9098 }
9099 }
9100 14080 }
9101 //Port quest rules to items
9102
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 14080 times.
14848 if( s_version <= 31)
9103 {
9104
2/2
✓ Branch 0 taken 65 times.
✓ Branch 1 taken 14015 times.
14080 if(tempitem.family == itype_bomb)
9105 {
9106
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 65 times.
65 if ( get_bit(quest_rules,qr_OUCHBOMBS) ) tempitem.flags |= ITEM_FLAG2;
9107 65 else tempitem.flags &= ~ ITEM_FLAG2;
9108 65 }
9109
2/2
✓ Branch 0 taken 55 times.
✓ Branch 1 taken 13960 times.
14015 else if(tempitem.family == itype_sbomb)
9110 {
9111
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
55 if ( get_bit(quest_rules,qr_OUCHBOMBS) ) tempitem.flags |= ITEM_FLAG2;
9112 55 else tempitem.flags &= ~ ITEM_FLAG2;
9113 55 }
9114
9115
2/2
✓ Branch 0 taken 165 times.
✓ Branch 1 taken 13795 times.
13960 else if(tempitem.family == itype_brang)
9116 {
9117
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 165 times.
165 if ( get_bit(quest_rules,qr_BRANGPICKUP) ) tempitem.flags |= ITEM_FLAG4;
9118 165 else tempitem.flags &= ~ ITEM_FLAG4;
9119 165 }
9120
2/2
✓ Branch 0 taken 13730 times.
✓ Branch 1 taken 65 times.
13795 else if(tempitem.family == itype_wand)
9121 {
9122
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 65 times.
65 if ( get_bit(quest_rules,qr_NOWANDMELEE) ) tempitem.flags |= ITEM_FLAG3;
9123 65 else tempitem.flags &= ~ ITEM_FLAG3;
9124 65 }
9125 14080 }
9126
9127 //Port quest rules to items
9128
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 14080 times.
14848 if( s_version <= 37)
9129 {
9130
2/2
✓ Branch 0 taken 55 times.
✓ Branch 1 taken 14025 times.
14080 if(tempitem.family == itype_flippers)
9131 {
9132
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
55 if ( (get_bit(quest_rules,qr_NODIVING)) ) tempitem.flags |= ITEM_FLAG1;
9133 55 else tempitem.flags &= ~ ITEM_FLAG1;
9134 55 }
9135
2/2
✓ Branch 0 taken 8901 times.
✓ Branch 1 taken 5124 times.
14025 else if(tempitem.family == itype_sword)
9136 {
9137
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5124 times.
5124 if ( (get_bit(quest_rules,qr_QUICKSWORD)) ) tempitem.flags |= ITEM_FLAG5;
9138 5124 else tempitem.flags &= ~ ITEM_FLAG5;
9139 5124 }
9140
2/2
✓ Branch 0 taken 65 times.
✓ Branch 1 taken 8836 times.
8901 else if(tempitem.family == itype_wand)
9141 {
9142
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 65 times.
65 if ( (get_bit(quest_rules,qr_QUICKSWORD)) ) tempitem.flags |= ITEM_FLAG5;
9143 65 else tempitem.flags &= ~ ITEM_FLAG5;
9144 65 }
9145
4/4
✓ Branch 0 taken 8771 times.
✓ Branch 1 taken 65 times.
✓ Branch 2 taken 143 times.
✓ Branch 3 taken 8628 times.
8836 else if(tempitem.family == itype_book || tempitem.family == itype_candle)
9146 {
9147 //@Emily: What was qrFIREPROOFHERO2 again, and does that also need to enable this?
9148
2/2
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 169 times.
208 if ( (get_bit(quest_rules,qr_FIREPROOFHERO)) ) tempitem.flags |= ITEM_FLAG3;
9149 169 else tempitem.flags &= ~ ITEM_FLAG3;
9150 208 }
9151 14080 }
9152
9153
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 14080 times.
14848 if( s_version < 38)
9154 {
9155
4/4
✓ Branch 0 taken 13915 times.
✓ Branch 1 taken 165 times.
✓ Branch 2 taken 110 times.
✓ Branch 3 taken 13805 times.
14080 if(tempitem.family == itype_brang || tempitem.family == itype_hookshot)
9156 {
9157
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 275 times.
275 if(get_bit(quest_rules,qr_BRANGPICKUP)) tempitem.flags |= ITEM_FLAG4;
9158 275 else tempitem.flags &= ~ITEM_FLAG4;
9159
9160
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 275 times.
275 if(get_bit(quest_rules,qr_Z3BRANG_HSHOT)) tempitem.flags |= ITEM_FLAG5 | ITEM_FLAG6;
9161 275 else tempitem.flags &= ~(ITEM_FLAG5|ITEM_FLAG6);
9162 275 }
9163
2/2
✓ Branch 0 taken 13640 times.
✓ Branch 1 taken 165 times.
13805 else if(tempitem.family == itype_arrow)
9164 {
9165
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 165 times.
165 if(get_bit(quest_rules,qr_BRANGPICKUP)) tempitem.flags |= ITEM_FLAG4;
9166 165 else tempitem.flags &= ~ITEM_FLAG4;
9167
9168
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 165 times.
165 if(get_bit(quest_rules,qr_Z3BRANG_HSHOT)) tempitem.flags &= ~ITEM_FLAG2;
9169 165 else tempitem.flags |= ITEM_FLAG2;
9170 165 }
9171 14080 }
9172
9173
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 14080 times.
14848 if( s_version < 39)
9174 {
9175
6/6
✓ Branch 0 taken 14025 times.
✓ Branch 1 taken 55 times.
✓ Branch 2 taken 13960 times.
✓ Branch 3 taken 65 times.
✓ Branch 4 taken 143 times.
✓ Branch 5 taken 13817 times.
14080 if(tempitem.family == itype_dinsfire || tempitem.family == itype_book || tempitem.family == itype_candle)
9176 {
9177
1/2
✓ Branch 0 taken 263 times.
✗ Branch 1 not taken.
263 if(get_bit(quest_rules,qr_TEMPCANDLELIGHT)) tempitem.flags |= ITEM_FLAG5;
9178 263 else tempitem.flags &= ~ITEM_FLAG5;
9179 263 }
9180
2/2
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 13707 times.
13817 else if(tempitem.family == itype_potion)
9181 {
9182
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 110 times.
110 if(get_bit(quest_rules,qr_NONBUBBLEMEDICINE))
9183 {
9184 tempitem.flags &= ~(ITEM_FLAG3|ITEM_FLAG4);
9185 }
9186 else
9187 {
9188 110 tempitem.flags |= ITEM_FLAG3;
9189
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 38 times.
110 if(get_bit(quest_rules,qr_ITEMBUBBLE))tempitem.flags |= ITEM_FLAG4;
9190 38 else tempitem.flags &= ~ITEM_FLAG4;
9191 }
9192 110 }
9193
2/2
✓ Branch 0 taken 13597 times.
✓ Branch 1 taken 110 times.
13707 else if(tempitem.family == itype_triforcepiece)
9194 {
9195
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 110 times.
110 if(get_bit(quest_rules,qr_NONBUBBLETRIFORCE))
9196 {
9197 tempitem.flags |= ITEM_FLAG3;
9198 if(get_bit(quest_rules,qr_ITEMBUBBLE))tempitem.flags |= ITEM_FLAG4;
9199 else tempitem.flags &= ~ITEM_FLAG4;
9200 }
9201 else
9202 {
9203 110 tempitem.flags &= ~(ITEM_FLAG3|ITEM_FLAG4);
9204 }
9205 110 }
9206 14080 }
9207
9208
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 14080 times.
14848 if( s_version < 40)
9209 {
9210
4/4
✓ Branch 0 taken 13915 times.
✓ Branch 1 taken 165 times.
✓ Branch 2 taken 55 times.
✓ Branch 3 taken 13860 times.
14080 if(tempitem.family == itype_ring || tempitem.family == itype_perilring)
9211 {
9212
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 220 times.
220 if(get_bit(quest_rules,qr_RINGAFFECTDAMAGE))tempitem.flags |= ITEM_FLAG1;
9213 220 else tempitem.flags &= ~ITEM_FLAG1;
9214 220 }
9215
8/8
✓ Branch 0 taken 13717 times.
✓ Branch 1 taken 143 times.
✓ Branch 2 taken 8593 times.
✓ Branch 3 taken 5124 times.
✓ Branch 4 taken 8528 times.
✓ Branch 5 taken 65 times.
✓ Branch 6 taken 55 times.
✓ Branch 7 taken 8473 times.
13860 else if(tempitem.family == itype_candle || tempitem.family == itype_sword || tempitem.family == itype_wand || tempitem.family == itype_cbyrna)
9216 {
9217
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5387 times.
5387 if(get_bit(quest_rules,qr_SLASHFLIPFIX))tempitem.flags |= ITEM_FLAG8;
9218 5387 else tempitem.flags &= ~ITEM_FLAG8;
9219 5387 }
9220
6/6
✓ Branch 0 taken 8956 times.
✓ Branch 1 taken 5124 times.
✓ Branch 2 taken 8891 times.
✓ Branch 3 taken 65 times.
✓ Branch 4 taken 55 times.
✓ Branch 5 taken 8836 times.
14080 if(tempitem.family == itype_sword || tempitem.family == itype_wand || tempitem.family == itype_hammer)
9221 {
9222
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5244 times.
5244 if(get_bit(quest_rules,qr_NOITEMMELEE))tempitem.flags |= ITEM_FLAG7;
9223 5244 else tempitem.flags &= ~ITEM_FLAG7;
9224 5244 }
9225
2/2
✓ Branch 0 taken 8781 times.
✓ Branch 1 taken 55 times.
8836 else if(tempitem.family == itype_cbyrna)
9226 {
9227 55 tempitem.flags |= ITEM_FLAG7;
9228 55 }
9229 14080 }
9230
9231
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 14080 times.
14848 if( s_version < 41 )
9232 {
9233
2/2
✓ Branch 0 taken 8956 times.
✓ Branch 1 taken 5124 times.
14080 if(tempitem.family == itype_sword)
9234 {
9235
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5124 times.
5124 if(get_bit(quest_rules,qr_SWORDMIRROR))tempitem.flags |= ITEM_FLAG9;
9236 5124 else tempitem.flags &= ~ITEM_FLAG9;
9237
9238
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5124 times.
5124 if(get_bit(quest_rules,qr_SLOWCHARGINGWALK))tempitem.flags |= ITEM_FLAG10;
9239 5124 else tempitem.flags &= ~ITEM_FLAG10;
9240 5124 }
9241 14080 }
9242
9243
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 14080 times.
14848 if( s_version < 42 )
9244 {
9245
2/2
✓ Branch 0 taken 65 times.
✓ Branch 1 taken 14015 times.
14080 if(tempitem.family == itype_wand)
9246 {
9247
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 65 times.
65 if(get_bit(quest_rules,qr_NOWANDMELEE))tempitem.flags |= ITEM_FLAG3;
9248 65 else tempitem.flags &= ~ITEM_FLAG3;
9249
9250 65 tempitem.flags &= ~ITEM_FLAG6;
9251 65 }
9252
2/2
✓ Branch 0 taken 55 times.
✓ Branch 1 taken 13960 times.
14015 else if(tempitem.family == itype_hammer)
9253 {
9254 55 tempitem.flags &= ~ITEM_FLAG3;
9255 55 }
9256
2/2
✓ Branch 0 taken 55 times.
✓ Branch 1 taken 13905 times.
13960 else if(tempitem.family == itype_cbyrna)
9257 {
9258 55 tempitem.flags |= ITEM_FLAG3;
9259
9260 55 tempitem.flags &= ~ITEM_FLAG6;
9261 55 }
9262
2/2
✓ Branch 0 taken 8781 times.
✓ Branch 1 taken 5124 times.
13905 else if(tempitem.family == itype_sword)
9263 {
9264
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5124 times.
5124 if(get_bit(quest_rules,qr_MELEEMAGICCOST))tempitem.flags |= ITEM_FLAG6;
9265 5124 else tempitem.flags &= ~ITEM_FLAG6;
9266 5124 }
9267 14080 }
9268
9269
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 14080 times.
14848 if( s_version < 43 )
9270 {
9271
2/2
✓ Branch 0 taken 13979 times.
✓ Branch 1 taken 101 times.
14080 if(tempitem.family == itype_whistle)
9272 {
9273
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 101 times.
101 if(get_bit(quest_rules,qr_WHIRLWINDMIRROR))tempitem.flags |= ITEM_FLAG3;
9274 101 else tempitem.flags &= ~ITEM_FLAG3;
9275 101 }
9276 14080 }
9277
9278
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 14080 times.
14848 if( s_version < 45 )
9279 {
9280
2/2
✓ Branch 0 taken 14025 times.
✓ Branch 1 taken 55 times.
14080 if(tempitem.family == itype_flippers)
9281 {
9282 55 tempitem.misc1 = 50; //Dive length, default 50 frames -V
9283 55 tempitem.misc2 = 30; //Dive cooldown, default 30 frames -V
9284 55 }
9285 14080 }
9286
9287
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 14080 times.
14848 if( s_version < 46 )
9288 {
9289
2/2
✓ Branch 0 taken 14025 times.
✓ Branch 1 taken 55 times.
14080 if(tempitem.family == itype_raft)
9290 {
9291 55 tempitem.misc1 = 1; //Rafting speed modifier; default 1. Negative slows, positive speeds.
9292 55 }
9293 14080 }
9294
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 14080 times.
14848 if ( s_version < 34 ) //! set the default counter for older quests.
9295 {
9296
2/2
✓ Branch 0 taken 55 times.
✓ Branch 1 taken 14025 times.
14080 if ( (tempitem.flags & ITEM_RUPEE_MAGIC) )
9297 {
9298 55 tempitem.cost_counter[0] = 1;
9299 55 }
9300 else
9301 {
9302
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14025 times.
14025 if(get_bit(quest_rules,qr_ENABLEMAGIC))
9303 tempitem.cost_counter[0] = 4;
9304 else
9305 {
9306 14025 tempitem.cost_amount[0] = 0;
9307 14025 tempitem.cost_counter[0] = -1;
9308 }
9309 }
9310 14080 }
9311
9312
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 14080 times.
14848 if ( s_version < 35 ) //new Lens of Truth flags
9313 {
9314
2/2
✓ Branch 0 taken 14025 times.
✓ Branch 1 taken 55 times.
14080 if ( tempitem.family == itype_lens )
9315 {
9316
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
55 if ( get_bit(quest_rules,qr_RAFTLENS) )
9317 {
9318 tempitem.flags |= ITEM_FLAG4;
9319 }
9320
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 32 times.
55 if ( get_bit(quest_rules,qr_LENSHINTS) )
9321 {
9322 23 tempitem.flags |= ITEM_FLAG1;
9323 23 }
9324
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
55 if ( get_bit(quest_rules,qr_LENSSEESENEMIES) )
9325 {
9326 tempitem.flags |= ITEM_FLAG5;
9327 }
9328 55 }
9329 14080 }
9330
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 14080 times.
14848 if ( s_version < 44 ) //InitD Labels and Sprite Script Data
9331 {
9332
2/2
✓ Branch 0 taken 112640 times.
✓ Branch 1 taken 14080 times.
126720 for ( int32_t q = 0; q < 8; q++ )
9333 {
9334 112640 sprintf(tempitem.initD_label[q],"InitD[%d]",q);
9335 112640 sprintf(tempitem.weapon_initD_label[q],"InitD[%d]",q);
9336 112640 sprintf(tempitem.sprite_initD_label[q],"InitD[%d]",q);
9337 112640 tempitem.sprite_initiald[q] = 0;
9338 112640 }
9339
2/2
✓ Branch 0 taken 28160 times.
✓ Branch 1 taken 14080 times.
42240 for ( int32_t q = 0; q < 2; q++ ) tempitem.sprite_initiala[q] = 0;
9340 14080 tempitem.sprite_script = 0;
9341 14080 }
9342
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 14080 times.
14848 if ( s_version < 47 ) //InitD Labels and Sprite Script Data
9343 {
9344 14080 tempitem.pickupflag = 0;
9345 14080 }
9346
9347
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 14080 times.
14848 if( s_version < 51 )
9348 {
9349
2/2
✓ Branch 0 taken 13937 times.
✓ Branch 1 taken 143 times.
14080 if( tempitem.family == itype_candle )
9350 {
9351 143 tempitem.misc4 = 50; //Step speed
9352 143 }
9353 14080 }
9354
9355
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 14080 times.
14848 if( s_version < 52 )
9356 {
9357
2/2
✓ Branch 0 taken 13915 times.
✓ Branch 1 taken 165 times.
14080 if( tempitem.family == itype_shield )
9358 165 tempitem.flags |= ITEM_FLAG1; //'Block Front' flag
9359 14080 }
9360
9361
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14848 times.
14848 if(tempitem.fam_type==0) // Always do this
9362 tempitem.fam_type=1;
9363
9364 14848 memcpy(&itemsbuf[i], &tempitem, sizeof(itemdata));
9365 14848 }
9366 58 }
9367
9368 58 return 0;
9369 58 }
9370
9371 static bool did_init_def_items = false;
9372 29696 void init_def_items()
9373 {
9374
2/2
✓ Branch 0 taken 29687 times.
✓ Branch 1 taken 9 times.
29696 if(did_init_def_items) return;
9375 9 did_init_def_items = true;
9376 9 default_items[3].cost_counter[1] = crBOMBS;
9377 9 default_items[13].cost_counter[1] = crARROWS;
9378 9 default_items[14].cost_counter[1] = crARROWS;
9379 9 default_items[48].cost_counter[1] = crBOMBS;
9380 9 default_items[57].cost_counter[1] = crARROWS;
9381 29696 }
9382 29696 void reset_itembuf(itemdata *item, int32_t id)
9383 {
9384 29696 init_def_items();
9385
2/2
✓ Branch 0 taken 13108 times.
✓ Branch 1 taken 16588 times.
29696 if(id<iLast)
9386 {
9387 // Copy everything *EXCEPT* the tile, misc, cset, frames, speed, delay and ltm.
9388 16588 word tile = item->tile;
9389 16588 byte miscs = item->misc_flags, cset = item->csets, frames = item->frames, speed = item->speed, delay = item->delay;
9390 16588 int32_t ltm = item->ltm;
9391
9392 16588 memcpy(item,&default_items[id],sizeof(itemdata));
9393 16588 item->tile = tile;
9394 16588 item->misc_flags = miscs;
9395 16588 item->csets = cset;
9396 16588 item->frames = frames;
9397 16588 item->speed = speed;
9398 16588 item->delay = delay;
9399 16588 item->ltm = ltm;
9400 16588 }
9401 29696 }
9402
9403 2304 void reset_itemname(int32_t id)
9404 {
9405 2304 sprintf(item_string[id],"zz%03d",id);
9406
9407
2/2
✓ Branch 0 taken 1017 times.
✓ Branch 1 taken 1287 times.
2304 if(id < iLast)
9408 1287 strcpy(item_string[id],old_item_string[id]);
9409 2304 }
9410
9411 58 int32_t readweapons(PACKFILE *f, zquestheader *Header, bool keepdata)
9412 {
9413 58 word weapons_to_read=MAXWPNS;
9414 int32_t dummy;
9415 byte padding;
9416 wpndata tempweapon;
9417 58 word s_version=0, s_cversion=0;
9418
9419
9420
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(Header->zelda_version < 0x186)
9421 {
9422 weapons_to_read=64;
9423 }
9424
9425
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(Header->zelda_version < 0x185)
9426 {
9427 weapons_to_read=32;
9428 }
9429
9430
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 if(Header->zelda_version > 0x192)
9431 {
9432 58 weapons_to_read=0;
9433
9434 //section version info
9435
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(!p_igetw(&s_version,f,true))
9436 {
9437 return qe_invalid;
9438 }
9439
9440 58 FFCore.quest_format[vWeaponSprites] = s_version;
9441
9442 //al_trace("Weapons version %d\n", s_version);
9443
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(!p_igetw(&s_cversion,f,true))
9444 {
9445 return qe_invalid;
9446 }
9447
9448 //section size
9449
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(!p_igetl(&dummy,f,true))
9450 {
9451 return qe_invalid;
9452 }
9453
9454 //finally... section data
9455
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(!p_igetw(&weapons_to_read,f,true))
9456 {
9457 return qe_invalid;
9458 }
9459 58 }
9460
9461
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(s_version>2)
9462 {
9463
2/2
✓ Branch 0 taken 14848 times.
✓ Branch 1 taken 58 times.
14906 for(int32_t i=0; i<weapons_to_read; i++)
9464 {
9465 char tempname[64];
9466
9467
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!pfread(tempname, 64, f, keepdata))
9468 {
9469 return qe_invalid;
9470 }
9471
9472
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14848 times.
14848 if(keepdata)
9473 {
9474 14848 strcpy(weapon_string[i], tempname);
9475 14848 }
9476 14848 }
9477
9478
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(s_version<4)
9479 {
9480 if(keepdata)
9481 {
9482 strcpy(weapon_string[iwHover],old_weapon_string[iwHover]);
9483 strcpy(weapon_string[wFIREMAGIC],old_weapon_string[wFIREMAGIC]);
9484 }
9485 }
9486
9487
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(s_version<5)
9488 {
9489 if(keepdata)
9490 {
9491 strcpy(weapon_string[iwQuarterHearts],old_weapon_string[iwQuarterHearts]);
9492 }
9493 }
9494
9495 /*
9496 if (s_version<6)
9497 {
9498 strcpy(weapon_string[iwSideRaft],old_weapon_string[iwSideRaft]);
9499 strcpy(weapon_string[iwSideLadder],old_weapon_string[iwSideLadder]);
9500 }
9501 */
9502 58 }
9503 else
9504 {
9505 if(keepdata)
9506 for(int32_t i=0; i<WPNCNT; i++)
9507 reset_weaponname(i);
9508 }
9509
9510
2/2
✓ Branch 0 taken 14848 times.
✓ Branch 1 taken 58 times.
14906 for(int32_t i=0; i<weapons_to_read; i++)
9511 {
9512 14848 word oldtile = 0;
9513
2/2
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 14336 times.
14848 if (s_version < 8)
9514 {
9515
1/2
✓ Branch 0 taken 14336 times.
✗ Branch 1 not taken.
14336 if (!p_igetw(&oldtile, f, true))
9516 return qe_invalid;
9517 14336 }
9518
9519
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_getc(&tempweapon.misc,f,true))
9520 {
9521 return qe_invalid;
9522 }
9523
9524
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_getc(&tempweapon.csets,f,true))
9525 {
9526 return qe_invalid;
9527 }
9528
9529
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_getc(&tempweapon.frames,f,true))
9530 {
9531 return qe_invalid;
9532 }
9533
9534
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_getc(&tempweapon.speed,f,true))
9535 {
9536 return qe_invalid;
9537 }
9538
9539
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_getc(&tempweapon.type,f,true))
9540 {
9541 return qe_invalid;
9542 }
9543
9544
2/2
✓ Branch 0 taken 14080 times.
✓ Branch 1 taken 768 times.
14848 if ( s_version >= 7 )
9545 {
9546
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_igetw(&tempweapon.script,f,true))
9547 {
9548 return qe_invalid;
9549 }
9550
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_igetl(&tempweapon.tile,f,true))
9551 {
9552 return qe_invalid;
9553 }
9554 768 }
9555
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 14080 times.
14848 if ( s_version < 7 )
9556 {
9557 14080 tempweapon.tile = oldtile;
9558 14080 }
9559
9560
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(Header->zelda_version < 0x193)
9561 {
9562 if(!p_getc(&padding,f,true))
9563 {
9564 return qe_invalid;
9565 }
9566 }
9567
9568
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(s_version < 6)
9569 {
9570 if(i==ewFIRETRAIL)
9571 {
9572 tempweapon.misc |= WF_BEHIND;
9573 }
9574 else
9575 tempweapon.misc &= ~WF_BEHIND;
9576 }
9577
9578
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14848 times.
14848 if(keepdata==true)
9579 {
9580 14848 memcpy(&wpnsbuf[i], &tempweapon, sizeof(tempweapon));
9581 14848 }
9582 14848 }
9583
9584
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 if(keepdata==true)
9585 {
9586
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(s_version<2)
9587 {
9588 wpnsbuf[wSBOOM]=wpnsbuf[wBOOM];
9589 }
9590
9591
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(s_version<5)
9592 {
9593 wpnsbuf[iwQuarterHearts].tile=1;
9594 wpnsbuf[iwQuarterHearts].csets=1;
9595 }
9596
9597
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(Header->zelda_version < 0x176)
9598 {
9599 wpnsbuf[iwSpawn] = *((wpndata*)(itemsbuf + iMisc1));
9600 wpnsbuf[iwDeath] = *((wpndata*)(itemsbuf + iMisc2));
9601 memset(&itemsbuf[iMisc1],0,sizeof(itemdata));
9602 memset(&itemsbuf[iMisc2],0,sizeof(itemdata));
9603 }
9604
9605
1/4
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
58 if((Header->zelda_version < 0x192)||
9606
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 ((Header->zelda_version == 0x192)&&(Header->build<129)))
9607 {
9608 wpnsbuf[wHSCHAIN_V] = wpnsbuf[wHSCHAIN_H];
9609 }
9610
9611
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if((Header->zelda_version < 0x210))
9612 {
9613 wpnsbuf[wLSHEAD] = wpnsbuf[wHSHEAD];
9614 wpnsbuf[wLSCHAIN_H] = wpnsbuf[wHSCHAIN_H];
9615 wpnsbuf[wLSHANDLE] = wpnsbuf[wHSHANDLE];
9616 wpnsbuf[wLSCHAIN_V] = wpnsbuf[wHSCHAIN_V];
9617 }
9618 58 }
9619
9620 58 return 0;
9621 58 }
9622
9623 58 void init_guys(int32_t guyversion)
9624 {
9625
2/2
✓ Branch 0 taken 29696 times.
✓ Branch 1 taken 58 times.
29754 for(int32_t i=0; i<MAXGUYS; i++)
9626 {
9627 29696 guysbuf[i] = default_guys[0];
9628 29696 }
9629
9630
2/2
✓ Branch 0 taken 10266 times.
✓ Branch 1 taken 58 times.
10324 for(int32_t i=0; i<OLDMAXGUYS; i++)
9631 {
9632 10266 guysbuf[i] = default_guys[i];
9633
2/2
✓ Branch 0 taken 10150 times.
✓ Branch 1 taken 116 times.
10266 guysbuf[i].spr_shadow = (guysbuf[i].family==eeROCK && guysbuf[i].misc10==1) ? iwLargeShadow : iwShadow;
9634 10266 guysbuf[i].spr_death = iwDeath;
9635 10266 guysbuf[i].spr_spawn = iwSpawn;
9636 // Patra fix: 2.10 BSPatras used spDIG. 2.50 Patras use CSet 7.
9637
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 10266 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
10266 if(guyversion<=3 && i==ePATRABS)
9638 {
9639 guysbuf[i].bosspal=spDIG;
9640 guysbuf[i].cset=14;
9641 guysbuf[i].misc9=14;
9642 }
9643
9644
1/2
✓ Branch 0 taken 10266 times.
✗ Branch 1 not taken.
10266 if(guyversion<=3)
9645 {
9646 // Rope/Ghini Flash rules
9647 if(get_bit(deprecated_rules, qr_NOROPE2FLASH_DEP))
9648 {
9649 if(i==eROPE2)
9650 {
9651 guysbuf[i].flags2 &= ~guy_flashing;
9652 }
9653 }
9654
9655 if(get_bit(deprecated_rules, qr_NOBUBBLEFLASH_DEP))
9656 {
9657 if(i==eBUBBLEST || i==eBUBBLESP || i==eBUBBLESR || i==eBUBBLEIT || i==eBUBBLEIP || i==eBUBBLEIR)
9658 {
9659 guysbuf[i].flags2 &= ~guy_flashing;
9660 }
9661 }
9662
9663 if(i==eGHINI2)
9664 {
9665 if(get_bit(deprecated_rules, qr_GHINI2BLINK_DEP))
9666 {
9667 guysbuf[i].flags2 |= guy_blinking;
9668 }
9669
9670 if(get_bit(deprecated_rules, qr_PHANTOMGHINI2_DEP))
9671 {
9672 guysbuf[i].flags2 |= guy_transparent;
9673 }
9674 }
9675 }
9676
9677 // Darknut fix
9678
10/10
✓ Branch 0 taken 10208 times.
✓ Branch 1 taken 58 times.
✓ Branch 2 taken 10150 times.
✓ Branch 3 taken 58 times.
✓ Branch 4 taken 10092 times.
✓ Branch 5 taken 58 times.
✓ Branch 6 taken 10034 times.
✓ Branch 7 taken 58 times.
✓ Branch 8 taken 58 times.
✓ Branch 9 taken 9976 times.
10266 if(i==eDKNUT1 || i==eDKNUT2 || i==eDKNUT3 || i==eDKNUT4 || i==eDKNUT5)
9679 {
9680
2/2
✓ Branch 0 taken 130 times.
✓ Branch 1 taken 160 times.
290 if(get_bit(quest_rules,qr_NEWENEMYTILES))
9681 {
9682 130 guysbuf[i].s_tile=guysbuf[i].e_tile+120;
9683 130 guysbuf[i].s_width=guysbuf[i].e_width;
9684 130 guysbuf[i].s_height=guysbuf[i].e_height;
9685 130 }
9686 160 else guysbuf[i].s_tile=860;
9687
9688
1/2
✓ Branch 0 taken 290 times.
✗ Branch 1 not taken.
290 if(get_bit(deprecated_rules,qr_BRKBLSHLDS_DEP))
9689 {
9690 guysbuf[i].flags |= guy_bkshield;
9691 }
9692 290 }
9693
9694
3/4
✓ Branch 0 taken 10208 times.
✓ Branch 1 taken 58 times.
✓ Branch 2 taken 10266 times.
✗ Branch 3 not taken.
10266 if((i==eGELTRIB || i==eFGELTRIB) && get_bit(deprecated_rules,qr_OLDTRIBBLES_DEP))
9695 {
9696 guysbuf[i].misc3 = (i==eFGELTRIB ? eFZOL : eZOL);
9697 }
9698 10266 }
9699 58 }
9700
9701 void reset_weaponname(int32_t i)
9702 {
9703 if(i<wLast)
9704 {
9705 strcpy(weapon_string[i],old_weapon_string[i]);
9706 }
9707 else
9708 sprintf(weapon_string[i],"zz%03d",i);
9709 }
9710
9711 58 void init_item_drop_sets()
9712 {
9713
2/2
✓ Branch 0 taken 14848 times.
✓ Branch 1 taken 58 times.
14906 for(int32_t i=0; i<MAXITEMDROPSETS; i++)
9714 {
9715 // item_drop_sets[i] = default_item_drop_sets[0];
9716 14848 memset(&item_drop_sets[i], 0, sizeof(item_drop_object));
9717 14848 }
9718
9719
2/2
✓ Branch 0 taken 754 times.
✓ Branch 1 taken 58 times.
812 for(int32_t i=0; i<isMAX; i++)
9720 {
9721 754 item_drop_sets[i] = default_item_drop_sets[i];
9722
9723 // Deprecated: qr_NOCLOCKS and qr_ALLOW10RUPEEDROPS
9724
2/2
✓ Branch 0 taken 7540 times.
✓ Branch 1 taken 754 times.
8294 for(int32_t j=0; j<10; ++j)
9725 {
9726 7540 int32_t it = item_drop_sets[i].item[j];
9727
9728
3/4
✓ Branch 0 taken 5336 times.
✓ Branch 1 taken 2204 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 348 times.
7540 if((itemsbuf[it].family == itype_rupee && ((itemsbuf[it].amount)&0xFFF) == 10)
9729
2/2
✓ Branch 0 taken 348 times.
✓ Branch 1 taken 4988 times.
5336 && !get_bit(deprecated_rules, qr_ALLOW10RUPEEDROPS_DEP))
9730 {
9731 348 item_drop_sets[i].chance[j+1]=0;
9732 348 }
9733
3/4
✓ Branch 0 taken 232 times.
✓ Branch 1 taken 6960 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 232 times.
7192 else if(itemsbuf[it].family == itype_clock && get_bit(deprecated_rules, qr_NOCLOCKS_DEP))
9734 {
9735 item_drop_sets[i].chance[j+1]=0;
9736 }
9737
9738 // From Sept 2007 to Dec 2008, non-gameplay items were prohibited.
9739
1/2
✓ Branch 0 taken 7540 times.
✗ Branch 1 not taken.
7540 if(itemsbuf[it].family == itype_misc)
9740 {
9741 // If a non-gameplay item was selected, then item drop was aborted.
9742 // Reflect this by increasing the 'Nothing' chance accordingly.
9743 item_drop_sets[i].chance[0]+=item_drop_sets[i].chance[j+1];
9744 item_drop_sets[i].chance[j+1]=0;
9745 }
9746 7540 }
9747 754 }
9748 58 }
9749
9750 58 void init_favorites()
9751 {
9752
2/2
✓ Branch 0 taken 5800 times.
✓ Branch 1 taken 58 times.
5858 for(int32_t i=0; i<MAXFAVORITECOMBOS; i++)
9753 {
9754 5800 favorite_combos[i]=-1;
9755 5800 }
9756
9757
2/2
✓ Branch 0 taken 5800 times.
✓ Branch 1 taken 58 times.
5858 for(int32_t i=0; i<MAXFAVORITECOMBOALIASES; i++)
9758 {
9759 5800 favorite_comboaliases[i]=-1;
9760 5800 }
9761 58 }
9762
9763 const char *ctype_name[cMAX]=
9764 {
9765 "cNONE", "cSTAIR", "cCAVE", "cWATER", "cARMOS", "cGRAVE", "cDOCK",
9766 "cUNDEF", "cPUSH_WAIT", "cPUSH_HEAVY", "cPUSH_HW", "cL_STATUE", "cR_STATUE",
9767 "cWALKSLOW", "cCVUP", "cCVDOWN", "cCVLEFT", "cCVRIGHT", "cSWIMWARP", "cDIVEWARP",
9768 "cLADDERHOOKSHOT", "cTRIGNOFLAG", "cTRIGFLAG", "cZELDA", "cSLASH", "cSLASHITEM",
9769 "cPUSH_HEAVY2", "cPUSH_HW2", "cPOUND", "cHSGRAB", "cHSBRIDGE", "cDAMAGE1",
9770 "cDAMAGE2", "cDAMAGE3", "cDAMAGE4", "cC_STATUE", "cTRAP_H", "cTRAP_V", "cTRAP_4",
9771 "cTRAP_LR", "cTRAP_UD", "cPIT", "cHOOKSHOTONLY", "cOVERHEAD", "cNOFLYZONE", "cMIRROR",
9772 "cMIRRORSLASH", "cMIRRORBACKSLASH", "cMAGICPRISM", "cMAGICPRISM4",
9773 "cMAGICSPONGE", "cCAVE2", "cEYEBALL_A", "cEYEBALL_B", "cNOJUMPZONE", "cBUSH",
9774 "cFLOWERS", "cTALLGRASS", "cSHALLOWWATER", "cLOCKBLOCK", "cLOCKBLOCK2",
9775 "cBOSSLOCKBLOCK", "cBOSSLOCKBLOCK2", "cLADDERONLY", "cBSGRAVE",
9776 "cCHEST", "cCHEST2", "cLOCKEDCHEST", "cLOCKEDCHEST2", "cBOSSCHEST", "cBOSSCHEST2",
9777 "cRESET", "cSAVE", "cSAVE2", "cCAVEB", "cCAVEC", "cCAVED",
9778 "cSTAIRB", "cSTAIRC", "cSTAIRD", "cPITB", "cPITC", "cPITD",
9779 "cCAVE2B", "cCAVE2C", "cCAVE2D", "cSWIMWARPB", "cSWIMWARPC", "cSWIMWARPD",
9780 "cDIVEWARPB", "cDIVEWARPC", "cDIVEWARPD", "cSTAIRR", "cPITR",
9781 "cAWARPA", "cAWARPB", "cAWARPC", "cAWARPD", "cAWARPR",
9782 "cSWARPA", "cSWARPB", "cSWARPC", "cSWARPD", "cSWARPR", "cSTRIGNOFLAG", "cSTRIGFLAG",
9783 "cSTEP", "cSTEPSAME", "cSTEPALL", "cSTEPCOPY", "cNOENEMY", "cBLOCKARROW1", "cBLOCKARROW2",
9784 "cBLOCKARROW3", "cBLOCKBRANG1", "cBLOCKBRANG2", "cBLOCKBRANG3", "cBLOCKSBEAM", "cBLOCKALL",
9785 "cBLOCKFIREBALL", "cDAMAGE5", "cDAMAGE6", "cDAMAGE7", "cCHANGE", "cSPINTILE1", "cSPINTILE2",
9786 "cSCREENFREEZE", "cSCREENFREEZEFF", "cNOGROUNDENEMY", "cSLASHNEXT", "cSLASHNEXTITEM", "cBUSHNEXT"
9787 "cSLASHTOUCHY", "cSLASHITEMTOUCHY", "cBUSHTOUCHY", "cFLOWERSTOUCHY", "cTALLGRASSTOUCHY",
9788 "cSLASHNEXTTOUCHY", "cSLASHNEXTITEMTOUCHY", "cBUSHNEXTTOUCHY", "cEYEBALL_4", "cTALLGRASSNEXT",
9789 "cSCRIPT1", "cSCRIPT2", "cSCRIPT3", "cSCRIPT4", "cSCRIPT5",
9790 "cSCRIPT6", "cSCRIPT7", "cSCRIPT8", "cSCRIPT9", "cSCRIPT10",
9791 "cSCRIPT11", "cSCRIPT12", "cSCRIPT13", "cSCRIPT14", "cSCRIPT15",
9792 "cSCRIPT16", "cSCRIPT17", "cSCRIPT18", "cSCRIPT19", "cSCRIPT20"
9793
9794 };
9795
9796 113 int32_t init_combo_classes()
9797 {
9798
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113 times.
113 zinfo* zi = (load_tmp_zi ? load_tmp_zi : &ZI);
9799
2/2
✓ Branch 0 taken 20114 times.
✓ Branch 1 taken 113 times.
20227 for(int32_t i=0; i<cMAX; i++)
9800 {
9801 20114 combo_class_buf[i] = default_combo_classes[i];
9802
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20114 times.
20114 if ( char const* nm = zi->getComboTypeName(i) )
9803 {
9804 20114 size_t len = strlen(nm);
9805
2/2
✓ Branch 0 taken 1287296 times.
✓ Branch 1 taken 20114 times.
1307410 for ( size_t q = 0; q < 64; q++ )
9806 {
9807
2/2
✓ Branch 0 taken 298094 times.
✓ Branch 1 taken 989202 times.
1287296 combo_class_buf[i].name[q] = (q<len ? nm[q] : 0);
9808 1287296 }
9809 20114 }
9810 20114 }
9811
9812 113 return 0;
9813 }
9814
9815 55 int32_t readherosprites2(PACKFILE *f, int32_t v_herosprites, int32_t cv_herosprites, bool keepdata)
9816 {
9817
1/2
✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
55 assert(v_herosprites < 6);
9818 //these are here to bypass compiler warnings about unused arguments
9819 55 cv_herosprites=cv_herosprites;
9820
9821
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
55 if(keepdata)
9822 {
9823 55 zinit.hero_swim_speed=67; //default
9824 55 setupherotiles(zinit.heroAnimationStyle);
9825 55 setupherodefenses();
9826 55 setupherooffsets();
9827 55 }
9828
9829
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
55 if(v_herosprites>=0)
9830 {
9831 word tile, tile2;
9832 byte flip, extend, dummy_byte;
9833
9834
2/2
✓ Branch 0 taken 220 times.
✓ Branch 1 taken 55 times.
275 for(int32_t i=0; i<4; i++)
9835 {
9836
1/2
✓ Branch 0 taken 220 times.
✗ Branch 1 not taken.
220 if(!p_igetw(&tile,f,keepdata))
9837 {
9838 return qe_invalid;
9839 }
9840
9841
1/2
✓ Branch 0 taken 220 times.
✗ Branch 1 not taken.
220 if(!p_getc(&flip,f,keepdata))
9842 {
9843 return qe_invalid;
9844 }
9845
9846
1/2
✓ Branch 0 taken 220 times.
✗ Branch 1 not taken.
220 if(!p_getc(&extend,f,keepdata))
9847 {
9848 return qe_invalid;
9849 }
9850
9851
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 220 times.
220 if(keepdata)
9852 {
9853 220 walkspr[i][spr_tile]=(int32_t)tile;
9854 220 walkspr[i][spr_flip]=(int32_t)flip;
9855 220 walkspr[i][spr_extend]=(int32_t)extend;
9856 220 }
9857 220 }
9858
9859
2/2
✓ Branch 0 taken 220 times.
✓ Branch 1 taken 55 times.
275 for(int32_t i=0; i<4; i++)
9860 {
9861
1/2
✓ Branch 0 taken 220 times.
✗ Branch 1 not taken.
220 if(!p_igetw(&tile,f,keepdata))
9862 {
9863 return qe_invalid;
9864 }
9865
9866
1/2
✓ Branch 0 taken 220 times.
✗ Branch 1 not taken.
220 if(!p_getc(&flip,f,keepdata))
9867 {
9868 return qe_invalid;
9869 }
9870
9871
1/2
✓ Branch 0 taken 220 times.
✗ Branch 1 not taken.
220 if(!p_getc(&extend,f,keepdata))
9872 {
9873 return qe_invalid;
9874 }
9875
9876
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 220 times.
220 if(keepdata)
9877 {
9878 220 stabspr[i][spr_tile]=(int32_t)tile;
9879 220 stabspr[i][spr_flip]=(int32_t)flip;
9880 220 stabspr[i][spr_extend]=(int32_t)extend;
9881 220 }
9882 220 }
9883
9884
2/2
✓ Branch 0 taken 220 times.
✓ Branch 1 taken 55 times.
275 for(int32_t i=0; i<4; i++)
9885 {
9886
1/2
✓ Branch 0 taken 220 times.
✗ Branch 1 not taken.
220 if(!p_igetw(&tile,f,keepdata))
9887 {
9888 return qe_invalid;
9889 }
9890
9891
1/2
✓ Branch 0 taken 220 times.
✗ Branch 1 not taken.
220 if(!p_getc(&flip,f,keepdata))
9892 {
9893 return qe_invalid;
9894 }
9895
9896
1/2
✓ Branch 0 taken 220 times.
✗ Branch 1 not taken.
220 if(!p_getc(&extend,f,keepdata))
9897 {
9898 return qe_invalid;
9899 }
9900
9901
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 220 times.
220 if(keepdata)
9902 {
9903 220 slashspr[i][spr_tile]=(int32_t)tile;
9904 220 slashspr[i][spr_flip]=(int32_t)flip;
9905 220 slashspr[i][spr_extend]=(int32_t)extend;
9906 220 }
9907 220 }
9908
9909
2/2
✓ Branch 0 taken 220 times.
✓ Branch 1 taken 55 times.
275 for(int32_t i=0; i<4; i++)
9910 {
9911
1/2
✓ Branch 0 taken 220 times.
✗ Branch 1 not taken.
220 if(!p_igetw(&tile,f,keepdata))
9912 {
9913 return qe_invalid;
9914 }
9915
9916
1/2
✓ Branch 0 taken 220 times.
✗ Branch 1 not taken.
220 if(!p_getc(&flip,f,keepdata))
9917 {
9918 return qe_invalid;
9919 }
9920
9921
1/2
✓ Branch 0 taken 220 times.
✗ Branch 1 not taken.
220 if(!p_getc(&extend,f,keepdata))
9922 {
9923 return qe_invalid;
9924 }
9925
9926
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 220 times.
220 if(keepdata)
9927 {
9928 220 floatspr[i][spr_tile]=(int32_t)tile;
9929 220 floatspr[i][spr_flip]=(int32_t)flip;
9930 220 floatspr[i][spr_extend]=(int32_t)extend;
9931 220 }
9932 220 }
9933
9934
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
55 if(v_herosprites>1)
9935 {
9936
2/2
✓ Branch 0 taken 220 times.
✓ Branch 1 taken 55 times.
275 for(int32_t i=0; i<4; i++)
9937 {
9938
1/2
✓ Branch 0 taken 220 times.
✗ Branch 1 not taken.
220 if(!p_igetw(&tile,f,keepdata))
9939 {
9940 return qe_invalid;
9941 }
9942
9943
1/2
✓ Branch 0 taken 220 times.
✗ Branch 1 not taken.
220 if(!p_getc(&flip,f,keepdata))
9944 {
9945 return qe_invalid;
9946 }
9947
9948
1/2
✓ Branch 0 taken 220 times.
✗ Branch 1 not taken.
220 if(!p_getc(&extend,f,keepdata))
9949 {
9950 return qe_invalid;
9951 }
9952
9953
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 220 times.
220 if(keepdata)
9954 {
9955 220 swimspr[i][spr_tile]=(int32_t)tile;
9956 220 swimspr[i][spr_flip]=(int32_t)flip;
9957 220 swimspr[i][spr_extend]=(int32_t)extend;
9958 220 }
9959 220 }
9960 55 }
9961
9962
2/2
✓ Branch 0 taken 220 times.
✓ Branch 1 taken 55 times.
275 for(int32_t i=0; i<4; i++)
9963 {
9964
1/2
✓ Branch 0 taken 220 times.
✗ Branch 1 not taken.
220 if(!p_igetw(&tile,f,keepdata))
9965 {
9966 return qe_invalid;
9967 }
9968
9969
1/2
✓ Branch 0 taken 220 times.
✗ Branch 1 not taken.
220 if(!p_getc(&flip,f,keepdata))
9970 {
9971 return qe_invalid;
9972 }
9973
9974
1/2
✓ Branch 0 taken 220 times.
✗ Branch 1 not taken.
220 if(!p_getc(&extend,f,keepdata))
9975 {
9976 return qe_invalid;
9977 }
9978
9979
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 220 times.
220 if(keepdata)
9980 {
9981 220 divespr[i][spr_tile]=(int32_t)tile;
9982 220 divespr[i][spr_flip]=(int32_t)flip;
9983 220 divespr[i][spr_extend]=(int32_t)extend;
9984 220 }
9985 220 }
9986
9987
2/2
✓ Branch 0 taken 220 times.
✓ Branch 1 taken 55 times.
275 for(int32_t i=0; i<4; i++)
9988 {
9989
1/2
✓ Branch 0 taken 220 times.
✗ Branch 1 not taken.
220 if(!p_igetw(&tile,f,keepdata))
9990 {
9991 return qe_invalid;
9992 }
9993
9994
1/2
✓ Branch 0 taken 220 times.
✗ Branch 1 not taken.
220 if(!p_getc(&flip,f,keepdata))
9995 {
9996 return qe_invalid;
9997 }
9998
9999
1/2
✓ Branch 0 taken 220 times.
✗ Branch 1 not taken.
220 if(!p_getc(&extend,f,keepdata))
10000 {
10001 return qe_invalid;
10002 }
10003
10004
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 220 times.
220 if(keepdata)
10005 {
10006 220 poundspr[i][spr_tile]=(int32_t)tile;
10007 220 poundspr[i][spr_flip]=(int32_t)flip;
10008 220 poundspr[i][spr_extend]=(int32_t)extend;
10009 220 }
10010 220 }
10011
10012
1/2
✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
55 if(!p_igetw(&tile,f,keepdata))
10013 {
10014 return qe_invalid;
10015 }
10016
10017 55 flip=0;
10018
10019
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
55 if(v_herosprites>0)
10020 {
10021
1/2
✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
55 if(!p_getc(&flip,f,keepdata))
10022 {
10023 return qe_invalid;
10024 }
10025 55 }
10026
10027
1/2
✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
55 if(!p_getc(&extend,f,keepdata))
10028 {
10029 return qe_invalid;
10030 }
10031
10032
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
55 if(keepdata)
10033 {
10034 55 castingspr[spr_tile]=(int32_t)tile;
10035 55 castingspr[spr_flip]=(int32_t)flip;
10036 55 castingspr[spr_extend]=(int32_t)extend;
10037 55 }
10038
10039
1/2
✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
55 if(v_herosprites>0)
10040 {
10041 55 int32_t num_holdsprs = (v_herosprites > 6 ? 3 : 2);
10042
2/2
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 55 times.
165 for(int32_t i=0; i<2; i++)
10043 {
10044
2/2
✓ Branch 0 taken 220 times.
✓ Branch 1 taken 110 times.
330 for(int32_t j=0; j<num_holdsprs; j++)
10045 {
10046
1/2
✓ Branch 0 taken 220 times.
✗ Branch 1 not taken.
220 if(!p_igetw(&tile,f,keepdata))
10047 {
10048 return qe_invalid;
10049 }
10050
10051
1/2
✓ Branch 0 taken 220 times.
✗ Branch 1 not taken.
220 if(!p_getc(&flip,f,keepdata))
10052 {
10053 return qe_invalid;
10054 }
10055
10056
1/2
✓ Branch 0 taken 220 times.
✗ Branch 1 not taken.
220 if(!p_getc(&extend,f,keepdata))
10057 {
10058 return qe_invalid;
10059 }
10060
10061
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 220 times.
220 if(keepdata)
10062 {
10063 220 holdspr[i][j][spr_tile]=(int32_t)tile;
10064 220 holdspr[i][j][spr_flip]=(int32_t)flip;
10065 220 holdspr[i][j][spr_extend]=(int32_t)extend;
10066 220 }
10067 220 }
10068 110 }
10069 55 }
10070 else
10071 {
10072 for(int32_t i=0; i<2; i++)
10073 {
10074 if(!p_igetw(&tile,f,keepdata))
10075 {
10076 return qe_invalid;
10077 }
10078
10079 if(!p_igetw(&tile2,f,keepdata))
10080 {
10081 return qe_invalid;
10082 }
10083
10084 if(!p_getc(&extend,f,keepdata))
10085 {
10086 return qe_invalid;
10087 }
10088
10089 if(keepdata)
10090 {
10091 holdspr[i][spr_hold1][spr_tile]=(int32_t)tile;
10092 holdspr[i][spr_hold1][spr_flip]=(int32_t)flip;
10093 holdspr[i][spr_hold1][spr_extend]=(int32_t)extend;
10094 holdspr[i][spr_hold2][spr_tile]=(int32_t)tile2;
10095 holdspr[i][spr_hold2][spr_flip]=(int32_t)flip;
10096 holdspr[i][spr_hold2][spr_extend]=(int32_t)extend;
10097 }
10098 }
10099 }
10100
10101
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
55 if(v_herosprites>2)
10102 {
10103
2/2
✓ Branch 0 taken 220 times.
✓ Branch 1 taken 55 times.
275 for(int32_t i=0; i<4; i++)
10104 {
10105
1/2
✓ Branch 0 taken 220 times.
✗ Branch 1 not taken.
220 if(!p_igetw(&tile,f,keepdata))
10106 {
10107 return qe_invalid;
10108 }
10109
10110
1/2
✓ Branch 0 taken 220 times.
✗ Branch 1 not taken.
220 if(!p_getc(&flip,f,keepdata))
10111 {
10112 return qe_invalid;
10113 }
10114
10115
1/2
✓ Branch 0 taken 220 times.
✗ Branch 1 not taken.
220 if(!p_getc(&extend,f,keepdata))
10116 {
10117 return qe_invalid;
10118 }
10119
10120
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 220 times.
220 if(keepdata)
10121 {
10122 220 jumpspr[i][spr_tile]=(int32_t)tile;
10123 220 jumpspr[i][spr_flip]=(int32_t)flip;
10124 220 jumpspr[i][spr_extend]=(int32_t)extend;
10125 220 }
10126 220 }
10127 55 }
10128
10129
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
55 if(v_herosprites>3)
10130 {
10131
2/2
✓ Branch 0 taken 220 times.
✓ Branch 1 taken 55 times.
275 for(int32_t i=0; i<4; i++)
10132 {
10133
1/2
✓ Branch 0 taken 220 times.
✗ Branch 1 not taken.
220 if(!p_igetw(&tile,f,keepdata))
10134 {
10135 return qe_invalid;
10136 }
10137
10138
1/2
✓ Branch 0 taken 220 times.
✗ Branch 1 not taken.
220 if(!p_getc(&flip,f,keepdata))
10139 {
10140 return qe_invalid;
10141 }
10142
10143
1/2
✓ Branch 0 taken 220 times.
✗ Branch 1 not taken.
220 if(!p_getc(&extend,f,keepdata))
10144 {
10145 return qe_invalid;
10146 }
10147
10148
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 220 times.
220 if(keepdata)
10149 {
10150 220 chargespr[i][spr_tile]=(int32_t)tile;
10151 220 chargespr[i][spr_flip]=(int32_t)flip;
10152 220 chargespr[i][spr_extend]=(int32_t)extend;
10153 220 }
10154 220 }
10155 55 }
10156
10157
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
55 if(v_herosprites>4)
10158 {
10159
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
55 if(!p_getc(&dummy_byte,f,keepdata))
10160 {
10161 return qe_invalid;
10162 }
10163
10164
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
55 if(keepdata)
10165 {
10166 55 zinit.hero_swim_speed=(byte)dummy_byte;
10167 55 }
10168 55 }
10169
10170
1/2
✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
55 if(keepdata)
10171 {
10172 55 memset(frozenspr, 0, sizeof(frozenspr));
10173 55 memset(frozen_waterspr, 0, sizeof(frozen_waterspr));
10174 55 memset(onfirespr, 0, sizeof(onfirespr));
10175 55 memset(onfire_waterspr, 0, sizeof(onfire_waterspr));
10176 55 memset(diggingspr, 0, sizeof(diggingspr));
10177 55 memset(usingrodspr, 0, sizeof(usingrodspr));
10178 55 memset(usingcanespr, 0, sizeof(usingcanespr));
10179 55 memset(pushingspr, 0, sizeof(pushingspr));
10180 55 memset(liftingspr, 0, sizeof(liftingspr));
10181 55 memset(liftingwalkspr, 0, sizeof(liftingwalkspr));
10182 55 memset(stunnedspr, 0, sizeof(stunnedspr));
10183 55 memset(stunned_waterspr, 0, sizeof(stunned_waterspr));
10184 55 memset(fallingspr, 0, sizeof(fallingspr));
10185 55 memset(shockedspr, 0, sizeof(shockedspr));
10186 55 memset(shocked_waterspr, 0, sizeof(shocked_waterspr));
10187 55 memset(pullswordspr, 0, sizeof(pullswordspr));
10188 55 memset(readingspr, 0, sizeof(readingspr));
10189 55 memset(slash180spr, 0, sizeof(slash180spr));
10190 55 memset(slashZ4spr, 0, sizeof(slashZ4spr));
10191 55 memset(dashspr, 0, sizeof(dashspr));
10192 55 memset(bonkspr, 0, sizeof(bonkspr));
10193 55 memset(medallionsprs, 0, sizeof(medallionsprs));
10194 55 memset(holdspr[0][2], 0, sizeof(holdspr[0][2])); //Sword hold (Land)
10195 55 memset(holdspr[1][2], 0, sizeof(holdspr[1][2])); //Sword hold (Water)
10196
2/2
✓ Branch 0 taken 220 times.
✓ Branch 1 taken 55 times.
275 for(int32_t q = 0; q < 4; ++q)
10197 {
10198
2/2
✓ Branch 0 taken 660 times.
✓ Branch 1 taken 220 times.
880 for(int32_t p = 0; p < 3; ++p)
10199 {
10200 660 drowningspr[q][p] = divespr[q][p];
10201 660 drowning_lavaspr[q][p] = divespr[q][p];
10202 660 }
10203 220 }
10204 55 memset(sideswimspr, 0, sizeof(sideswimspr));
10205 55 memset(sideswimslashspr, 0, sizeof(sideswimslashspr));
10206 55 memset(sideswimstabspr, 0, sizeof(sideswimstabspr));
10207 55 memset(sideswimpoundspr, 0, sizeof(sideswimpoundspr));
10208 55 memset(sideswimchargespr, 0, sizeof(sideswimchargespr));
10209 55 memset(sideswimholdspr, 0, sizeof(sideswimholdspr));
10210 55 memset(sidedrowningspr, 0, sizeof(sidedrowningspr));
10211 55 }
10212 55 }
10213
10214 55 return 0;
10215 55 }
10216
10217 510 void setSprite(int32_t* arr, int32_t tile, int32_t flip, int32_t ext)
10218 {
10219 510 arr[spr_tile] = tile;
10220
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 510 times.
510 arr[spr_flip] = (flip > 3 ? 0 : flip);
10221
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 510 times.
510 arr[spr_extend] = (ext > 2 ? 0 : ext);
10222 510 }
10223 //Used to read the player sprites as int32_t, not word.
10224 3 int32_t readherosprites3(PACKFILE *f, int32_t v_herosprites, int32_t cv_herosprites, bool keepdata)
10225 {
10226 //these are here to bypass compiler warnings about unused arguments
10227 3 cv_herosprites=cv_herosprites;
10228
10229
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(keepdata)
10230 {
10231 3 zinit.hero_swim_speed=67; //default
10232 3 setupherotiles(zinit.heroAnimationStyle);
10233 3 setupherodefenses();
10234 3 setupherooffsets();
10235 3 }
10236
10237 int32_t tile, tile2;
10238 byte flip, extend, dummy_byte;
10239
10240
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(v_herosprites>=0)
10241 {
10242
10243
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 3 times.
15 for(int32_t i=0; i<4; i++)
10244 {
10245
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetl(&tile,f,keepdata))
10246 {
10247 return qe_invalid;
10248 }
10249
10250
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!p_getc(&flip,f,keepdata))
10251 {
10252 return qe_invalid;
10253 }
10254
10255
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!p_getc(&extend,f,keepdata))
10256 {
10257 return qe_invalid;
10258 }
10259
10260 12 if(keepdata)
10261 {
10262 12 setSprite(walkspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10263 12 }
10264 12 }
10265
10266
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 3 times.
15 for(int32_t i=0; i<4; i++)
10267 {
10268
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetl(&tile,f,keepdata))
10269 {
10270 return qe_invalid;
10271 }
10272
10273
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!p_getc(&flip,f,keepdata))
10274 {
10275 return qe_invalid;
10276 }
10277
10278
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!p_getc(&extend,f,keepdata))
10279 {
10280 return qe_invalid;
10281 }
10282
10283
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(keepdata)
10284 {
10285 12 setSprite(stabspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10286 12 }
10287 12 }
10288
10289
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 3 times.
15 for(int32_t i=0; i<4; i++)
10290 {
10291
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetl(&tile,f,keepdata))
10292 {
10293 return qe_invalid;
10294 }
10295
10296
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!p_getc(&flip,f,keepdata))
10297 {
10298 return qe_invalid;
10299 }
10300
10301
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!p_getc(&extend,f,keepdata))
10302 {
10303 return qe_invalid;
10304 }
10305
10306
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(keepdata)
10307 {
10308 12 setSprite(slashspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10309 12 }
10310 12 }
10311
10312
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 3 times.
15 for(int32_t i=0; i<4; i++)
10313 {
10314
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetl(&tile,f,keepdata))
10315 {
10316 return qe_invalid;
10317 }
10318
10319
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!p_getc(&flip,f,keepdata))
10320 {
10321 return qe_invalid;
10322 }
10323
10324
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!p_getc(&extend,f,keepdata))
10325 {
10326 return qe_invalid;
10327 }
10328
10329
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(keepdata)
10330 {
10331 12 setSprite(floatspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10332 12 }
10333 12 }
10334
10335
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(v_herosprites>1)
10336 {
10337
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 3 times.
15 for(int32_t i=0; i<4; i++)
10338 {
10339
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetl(&tile,f,keepdata))
10340 {
10341 return qe_invalid;
10342 }
10343
10344
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!p_getc(&flip,f,keepdata))
10345 {
10346 return qe_invalid;
10347 }
10348
10349
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!p_getc(&extend,f,keepdata))
10350 {
10351 return qe_invalid;
10352 }
10353
10354
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(keepdata)
10355 {
10356 12 setSprite(swimspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10357 12 }
10358 12 }
10359 3 }
10360
10361
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 3 times.
15 for(int32_t i=0; i<4; i++)
10362 {
10363
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetl(&tile,f,keepdata))
10364 {
10365 return qe_invalid;
10366 }
10367
10368
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!p_getc(&flip,f,keepdata))
10369 {
10370 return qe_invalid;
10371 }
10372
10373
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!p_getc(&extend,f,keepdata))
10374 {
10375 return qe_invalid;
10376 }
10377
10378
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(keepdata)
10379 {
10380 12 setSprite(divespr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10381 12 }
10382 12 }
10383
10384
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 3 times.
15 for(int32_t i=0; i<4; i++)
10385 {
10386
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetl(&tile,f,keepdata))
10387 {
10388 return qe_invalid;
10389 }
10390
10391
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!p_getc(&flip,f,keepdata))
10392 {
10393 return qe_invalid;
10394 }
10395
10396
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!p_getc(&extend,f,keepdata))
10397 {
10398 return qe_invalid;
10399 }
10400
10401
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(keepdata)
10402 {
10403 12 setSprite(poundspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10404 12 }
10405 12 }
10406
10407
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_igetl(&tile,f,keepdata))
10408 {
10409 return qe_invalid;
10410 }
10411
10412 3 flip=0;
10413
10414
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(v_herosprites>0)
10415 {
10416
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_getc(&flip,f,keepdata))
10417 {
10418 return qe_invalid;
10419 }
10420 3 }
10421
10422
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_getc(&extend,f,keepdata))
10423 {
10424 return qe_invalid;
10425 }
10426
10427
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(keepdata)
10428 {
10429 3 setSprite(castingspr, int32_t(tile), int32_t(flip), int32_t(extend));
10430 3 }
10431
10432
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(v_herosprites>0)
10433 {
10434 3 int32_t num_holdsprs = (v_herosprites > 6 ? 3 : 2);
10435
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 3 times.
9 for(int32_t i=0; i<2; i++)
10436 {
10437
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 6 times.
24 for(int32_t j=0; j<num_holdsprs; j++)
10438 {
10439
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_igetl(&tile,f,keepdata))
10440 {
10441 return qe_invalid;
10442 }
10443
10444
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if(!p_getc(&flip,f,keepdata))
10445 {
10446 return qe_invalid;
10447 }
10448
10449
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if(!p_getc(&extend,f,keepdata))
10450 {
10451 return qe_invalid;
10452 }
10453
10454
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if(keepdata)
10455 {
10456 18 setSprite(holdspr[i][j], int32_t(tile), int32_t(flip), int32_t(extend));
10457 18 }
10458 18 }
10459 6 }
10460 3 }
10461 else
10462 {
10463 for(int32_t i=0; i<2; i++)
10464 {
10465 if(!p_igetl(&tile,f,keepdata))
10466 {
10467 return qe_invalid;
10468 }
10469
10470 if(!p_igetl(&tile2,f,keepdata))
10471 {
10472 return qe_invalid;
10473 }
10474
10475 if(!p_getc(&extend,f,keepdata))
10476 {
10477 return qe_invalid;
10478 }
10479
10480 if(keepdata)
10481 {
10482 setSprite(holdspr[i][spr_hold1], int32_t(tile), int32_t(flip), int32_t(extend));
10483 setSprite(holdspr[i][spr_hold2], int32_t(tile2), int32_t(flip), int32_t(extend));
10484 }
10485 }
10486 }
10487
10488
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(v_herosprites>2)
10489 {
10490
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 3 times.
15 for(int32_t i=0; i<4; i++)
10491 {
10492
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetl(&tile,f,keepdata))
10493 {
10494 return qe_invalid;
10495 }
10496
10497
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!p_getc(&flip,f,keepdata))
10498 {
10499 return qe_invalid;
10500 }
10501
10502
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!p_getc(&extend,f,keepdata))
10503 {
10504 return qe_invalid;
10505 }
10506
10507
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(keepdata)
10508 {
10509 12 setSprite(jumpspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10510 12 }
10511 12 }
10512 3 }
10513
10514
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(v_herosprites>3)
10515 {
10516
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 3 times.
15 for(int32_t i=0; i<4; i++)
10517 {
10518
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetl(&tile,f,keepdata))
10519 {
10520 return qe_invalid;
10521 }
10522
10523
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!p_getc(&flip,f,keepdata))
10524 {
10525 return qe_invalid;
10526 }
10527
10528
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!p_getc(&extend,f,keepdata))
10529 {
10530 return qe_invalid;
10531 }
10532
10533
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(keepdata)
10534 {
10535 12 setSprite(chargespr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10536 12 }
10537 12 }
10538 3 }
10539
10540
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(v_herosprites>4)
10541 {
10542
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_getc(&dummy_byte,f,keepdata))
10543 {
10544 return qe_invalid;
10545 }
10546
10547
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(keepdata)
10548 {
10549 3 zinit.hero_swim_speed=(byte)dummy_byte;
10550 3 }
10551 3 }
10552
10553
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(v_herosprites>6)
10554 {
10555
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 3 times.
15 for(int32_t q = 0; q < 4; ++q)
10556 {
10557
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetl(&tile,f,keepdata))
10558 return qe_invalid;
10559
10560
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!p_getc(&flip,f,keepdata))
10561 return qe_invalid;
10562
10563
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!p_getc(&extend,f,keepdata))
10564 return qe_invalid;
10565
10566
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(keepdata)
10567 {
10568 12 setSprite(frozenspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10569 12 }
10570 12 }
10571
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 3 times.
15 for(int32_t q = 0; q < 4; ++q)
10572 {
10573
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetl(&tile,f,keepdata))
10574 return qe_invalid;
10575
10576
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!p_getc(&flip,f,keepdata))
10577 return qe_invalid;
10578
10579
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!p_getc(&extend,f,keepdata))
10580 return qe_invalid;
10581
10582
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(keepdata)
10583 {
10584 12 setSprite(frozen_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10585 12 }
10586 12 }
10587
10588
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 3 times.
15 for(int32_t q = 0; q < 4; ++q)
10589 {
10590
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetl(&tile,f,keepdata))
10591 return qe_invalid;
10592
10593
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!p_getc(&flip,f,keepdata))
10594 return qe_invalid;
10595
10596
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!p_getc(&extend,f,keepdata))
10597 return qe_invalid;
10598
10599
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(keepdata)
10600 {
10601 12 setSprite(onfirespr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10602 12 }
10603 12 }
10604
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 3 times.
15 for(int32_t q = 0; q < 4; ++q)
10605 {
10606
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetl(&tile,f,keepdata))
10607 return qe_invalid;
10608
10609
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!p_getc(&flip,f,keepdata))
10610 return qe_invalid;
10611
10612
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!p_getc(&extend,f,keepdata))
10613 return qe_invalid;
10614
10615
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(keepdata)
10616 {
10617 12 setSprite(onfire_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10618 12 }
10619 12 }
10620
10621
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 3 times.
15 for(int32_t q = 0; q < 4; ++q)
10622 {
10623
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetl(&tile,f,keepdata))
10624 return qe_invalid;
10625
10626
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!p_getc(&flip,f,keepdata))
10627 return qe_invalid;
10628
10629
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!p_getc(&extend,f,keepdata))
10630 return qe_invalid;
10631
10632
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(keepdata)
10633 {
10634 12 setSprite(diggingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10635 12 }
10636 12 }
10637
10638
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 3 times.
15 for(int32_t q = 0; q < 4; ++q)
10639 {
10640
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetl(&tile,f,keepdata))
10641 return qe_invalid;
10642
10643
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&flip,f,keepdata))
10644 return qe_invalid;
10645
10646
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!p_getc(&extend,f,keepdata))
10647 return qe_invalid;
10648
10649
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(keepdata)
10650 {
10651 12 setSprite(usingrodspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10652 12 }
10653 12 }
10654
10655
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 3 times.
15 for(int32_t q = 0; q < 4; ++q)
10656 {
10657
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetl(&tile,f,keepdata))
10658 return qe_invalid;
10659
10660
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&flip,f,keepdata))
10661 return qe_invalid;
10662
10663
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&extend,f,keepdata))
10664 return qe_invalid;
10665
10666
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(keepdata)
10667 {
10668 12 setSprite(usingcanespr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10669 12 }
10670 12 }
10671
10672
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 3 times.
15 for(int32_t q = 0; q < 4; ++q)
10673 {
10674
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetl(&tile,f,keepdata))
10675 return qe_invalid;
10676
10677
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!p_getc(&flip,f,keepdata))
10678 return qe_invalid;
10679
10680
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!p_getc(&extend,f,keepdata))
10681 return qe_invalid;
10682
10683
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(keepdata)
10684 {
10685 12 setSprite(pushingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10686 12 }
10687 12 }
10688
10689
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 3 times.
15 for(int32_t q = 0; q < 4; ++q)
10690 {
10691
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetl(&tile,f,keepdata))
10692 return qe_invalid;
10693
10694
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&flip,f,keepdata))
10695 return qe_invalid;
10696
10697
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&extend,f,keepdata))
10698 return qe_invalid;
10699
10700 12 byte frames = 0;
10701
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(v_herosprites > 15)
10702 {
10703
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!p_getc(&frames,f,keepdata))
10704 return qe_invalid;
10705 12 }
10706
10707
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(keepdata)
10708 {
10709 12 setSprite(liftingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10710 12 liftingspr[q][spr_frames] = frames;
10711 12 }
10712 12 }
10713
10714
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 3 times.
15 for(int32_t q = 0; q < 4; ++q)
10715 {
10716
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetl(&tile,f,keepdata))
10717 return qe_invalid;
10718
10719
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&flip,f,keepdata))
10720 return qe_invalid;
10721
10722
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&extend,f,keepdata))
10723 return qe_invalid;
10724
10725
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(keepdata)
10726 {
10727 12 setSprite(liftingwalkspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10728 12 }
10729 12 }
10730
10731
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 3 times.
15 for(int32_t q = 0; q < 4; ++q)
10732 {
10733
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!p_igetl(&tile,f,keepdata))
10734 return qe_invalid;
10735
10736
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&flip,f,keepdata))
10737 return qe_invalid;
10738
10739
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!p_getc(&extend,f,keepdata))
10740 return qe_invalid;
10741
10742
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(keepdata)
10743 {
10744 12 setSprite(stunnedspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10745 12 }
10746 12 }
10747
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 3 times.
15 for(int32_t q = 0; q < 4; ++q)
10748 {
10749
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetl(&tile,f,keepdata))
10750 return qe_invalid;
10751
10752
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&flip,f,keepdata))
10753 return qe_invalid;
10754
10755
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&extend,f,keepdata))
10756 return qe_invalid;
10757
10758
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(keepdata)
10759 {
10760 12 setSprite(stunned_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10761 12 }
10762 12 }
10763
10764
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 3 times.
15 for(int32_t q = 0; q < 4; ++q)
10765 {
10766
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetl(&tile,f,keepdata))
10767 return qe_invalid;
10768
10769
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&flip,f,keepdata))
10770 return qe_invalid;
10771
10772
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!p_getc(&extend,f,keepdata))
10773 return qe_invalid;
10774
10775
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(keepdata)
10776 {
10777 12 setSprite(drowningspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10778 12 }
10779 12 }
10780
10781
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 3 times.
15 for(int32_t q = 0; q < 4; ++q)
10782 {
10783
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetl(&tile,f,keepdata))
10784 return qe_invalid;
10785
10786
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&flip,f,keepdata))
10787 return qe_invalid;
10788
10789
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&extend,f,keepdata))
10790 return qe_invalid;
10791
10792
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(keepdata)
10793 {
10794 12 setSprite(drowning_lavaspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10795 12 }
10796 12 }
10797
10798
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 3 times.
15 for(int32_t q = 0; q < 4; ++q)
10799 {
10800
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetl(&tile,f,keepdata))
10801 return qe_invalid;
10802
10803
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&flip,f,keepdata))
10804 return qe_invalid;
10805
10806
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&extend,f,keepdata))
10807 return qe_invalid;
10808
10809
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(keepdata)
10810 {
10811 12 setSprite(fallingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10812 12 }
10813 12 }
10814
10815
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 3 times.
15 for(int32_t q = 0; q < 4; ++q)
10816 {
10817
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetl(&tile,f,keepdata))
10818 return qe_invalid;
10819
10820
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&flip,f,keepdata))
10821 return qe_invalid;
10822
10823
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&extend,f,keepdata))
10824 return qe_invalid;
10825
10826
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(keepdata)
10827 {
10828 12 setSprite(shockedspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10829 12 }
10830 12 }
10831
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 3 times.
15 for(int32_t q = 0; q < 4; ++q)
10832 {
10833
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetl(&tile,f,keepdata))
10834 return qe_invalid;
10835
10836
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&flip,f,keepdata))
10837 return qe_invalid;
10838
10839
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&extend,f,keepdata))
10840 return qe_invalid;
10841
10842
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(keepdata)
10843 {
10844 12 setSprite(shocked_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10845 12 }
10846 12 }
10847
10848
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 3 times.
15 for(int32_t q = 0; q < 4; ++q)
10849 {
10850
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetl(&tile,f,keepdata))
10851 return qe_invalid;
10852
10853
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!p_getc(&flip,f,keepdata))
10854 return qe_invalid;
10855
10856
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!p_getc(&extend,f,keepdata))
10857 return qe_invalid;
10858
10859
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(keepdata)
10860 {
10861 12 setSprite(pullswordspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10862 12 }
10863 12 }
10864
10865
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 3 times.
15 for(int32_t q = 0; q < 4; ++q)
10866 {
10867
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetl(&tile,f,keepdata))
10868 return qe_invalid;
10869
10870
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&flip,f,keepdata))
10871 return qe_invalid;
10872
10873
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&extend,f,keepdata))
10874 return qe_invalid;
10875
10876
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(keepdata)
10877 {
10878 12 setSprite(readingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10879 12 }
10880 12 }
10881
10882
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 3 times.
15 for(int32_t q = 0; q < 4; ++q)
10883 {
10884
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!p_igetl(&tile,f,keepdata))
10885 return qe_invalid;
10886
10887
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&flip,f,keepdata))
10888 return qe_invalid;
10889
10890
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!p_getc(&extend,f,keepdata))
10891 return qe_invalid;
10892
10893
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(keepdata)
10894 {
10895 12 setSprite(slash180spr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10896 12 }
10897 12 }
10898
10899
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 3 times.
15 for(int32_t q = 0; q < 4; ++q)
10900 {
10901
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetl(&tile,f,keepdata))
10902 return qe_invalid;
10903
10904
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&flip,f,keepdata))
10905 return qe_invalid;
10906
10907
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&extend,f,keepdata))
10908 return qe_invalid;
10909
10910
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(keepdata)
10911 {
10912 12 setSprite(slashZ4spr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10913 12 }
10914 12 }
10915
10916
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 3 times.
15 for(int32_t q = 0; q < 4; ++q)
10917 {
10918
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetl(&tile,f,keepdata))
10919 return qe_invalid;
10920
10921
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&flip,f,keepdata))
10922 return qe_invalid;
10923
10924
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&extend,f,keepdata))
10925 return qe_invalid;
10926
10927
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(keepdata)
10928 {
10929 12 setSprite(dashspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10930 12 }
10931 12 }
10932
10933
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 3 times.
15 for(int32_t q = 0; q < 4; ++q)
10934 {
10935
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetl(&tile,f,keepdata))
10936 return qe_invalid;
10937
10938
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&flip,f,keepdata))
10939 return qe_invalid;
10940
10941
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&extend,f,keepdata))
10942 return qe_invalid;
10943
10944
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(keepdata)
10945 {
10946 12 setSprite(bonkspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10947 12 }
10948 12 }
10949
10950
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 3 times.
12 for(int32_t q = 0; q < 3; ++q) //Not directions; number of medallion sprs
10951 {
10952
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_igetl(&tile,f,keepdata))
10953 return qe_invalid;
10954
10955
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&flip,f,keepdata))
10956 return qe_invalid;
10957
10958
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&extend,f,keepdata))
10959 return qe_invalid;
10960
10961
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(keepdata)
10962 {
10963 9 setSprite(medallionsprs[q], int32_t(tile), int32_t(flip), int32_t(extend));
10964 9 }
10965 9 }
10966 3 }
10967 else if(keepdata)
10968 {
10969 memset(frozenspr, 0, sizeof(frozenspr));
10970 memset(frozen_waterspr, 0, sizeof(frozen_waterspr));
10971 memset(onfirespr, 0, sizeof(onfirespr));
10972 memset(onfire_waterspr, 0, sizeof(onfire_waterspr));
10973 memset(diggingspr, 0, sizeof(diggingspr));
10974 memset(usingrodspr, 0, sizeof(usingrodspr));
10975 memset(usingcanespr, 0, sizeof(usingcanespr));
10976 memset(pushingspr, 0, sizeof(pushingspr));
10977 memset(liftingspr, 0, sizeof(liftingspr));
10978 memset(liftingwalkspr, 0, sizeof(liftingwalkspr));
10979 memset(stunnedspr, 0, sizeof(stunnedspr));
10980 memset(stunned_waterspr, 0, sizeof(stunned_waterspr));
10981 memset(fallingspr, 0, sizeof(fallingspr));
10982 memset(shockedspr, 0, sizeof(shockedspr));
10983 memset(shocked_waterspr, 0, sizeof(shocked_waterspr));
10984 memset(pullswordspr, 0, sizeof(pullswordspr));
10985 memset(readingspr, 0, sizeof(readingspr));
10986 memset(slash180spr, 0, sizeof(slash180spr));
10987 memset(slashZ4spr, 0, sizeof(slashZ4spr));
10988 memset(dashspr, 0, sizeof(dashspr));
10989 memset(bonkspr, 0, sizeof(bonkspr));
10990 memset(medallionsprs, 0, sizeof(medallionsprs));
10991 memset(holdspr[0][2], 0, sizeof(holdspr[0][2])); //Sword hold (Land)
10992 memset(holdspr[1][2], 0, sizeof(holdspr[1][2])); //Sword hold (Water)
10993 for(int32_t q = 0; q < 4; ++q)
10994 {
10995 for(int32_t p = 0; p < 3; ++p)
10996 {
10997 drowningspr[q][p] = divespr[q][p];
10998 drowning_lavaspr[q][p] = divespr[q][p];
10999 }
11000 }
11001 }
11002
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if (v_herosprites > 8)
11003 {
11004
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 3 times.
15 for(int32_t q = 0; q < 4; ++q)
11005 {
11006
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetl(&tile,f,keepdata))
11007 return qe_invalid;
11008
11009
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!p_getc(&flip,f,keepdata))
11010 return qe_invalid;
11011
11012
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!p_getc(&extend,f,keepdata))
11013 return qe_invalid;
11014
11015
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(keepdata)
11016 {
11017 12 setSprite(sideswimspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11018 12 }
11019 12 }
11020 3 }
11021 else if (keepdata)
11022 {
11023 memset(sideswimspr, 0, sizeof(sideswimspr));
11024 }
11025
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if (v_herosprites > 9)
11026 {
11027
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 3 times.
15 for(int32_t q = 0; q < 4; ++q)
11028 {
11029
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetl(&tile,f,keepdata))
11030 return qe_invalid;
11031
11032
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!p_getc(&flip,f,keepdata))
11033 return qe_invalid;
11034
11035
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!p_getc(&extend,f,keepdata))
11036 return qe_invalid;
11037
11038
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(keepdata)
11039 {
11040 12 setSprite(sideswimslashspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11041 12 }
11042 12 }
11043
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 3 times.
15 for(int32_t q = 0; q < 4; ++q)
11044 {
11045
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetl(&tile,f,keepdata))
11046 return qe_invalid;
11047
11048
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!p_getc(&flip,f,keepdata))
11049 return qe_invalid;
11050
11051
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!p_getc(&extend,f,keepdata))
11052 return qe_invalid;
11053
11054
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(keepdata)
11055 {
11056 12 setSprite(sideswimstabspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11057 12 }
11058 12 }
11059
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 3 times.
15 for(int32_t q = 0; q < 4; ++q)
11060 {
11061
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetl(&tile,f,keepdata))
11062 return qe_invalid;
11063
11064
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!p_getc(&flip,f,keepdata))
11065 return qe_invalid;
11066
11067
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!p_getc(&extend,f,keepdata))
11068 return qe_invalid;
11069
11070
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(keepdata)
11071 {
11072 12 setSprite(sideswimpoundspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11073 12 }
11074 12 }
11075
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 3 times.
15 for(int32_t q = 0; q < 4; ++q)
11076 {
11077
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetl(&tile,f,keepdata))
11078 return qe_invalid;
11079
11080
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!p_getc(&flip,f,keepdata))
11081 return qe_invalid;
11082
11083
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!p_getc(&extend,f,keepdata))
11084 return qe_invalid;
11085
11086
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(keepdata)
11087 {
11088 12 setSprite(sideswimchargespr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11089 12 }
11090 12 }
11091 3 }
11092 else if (keepdata)
11093 {
11094 memset(sideswimslashspr, 0, sizeof(sideswimslashspr));
11095 memset(sideswimstabspr, 0, sizeof(sideswimstabspr));
11096 memset(sideswimpoundspr, 0, sizeof(sideswimpoundspr));
11097 memset(sideswimchargespr, 0, sizeof(sideswimchargespr));
11098 }
11099
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if (v_herosprites > 10)
11100 {
11101
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 3 times.
15 for(int32_t q = 0; q < 4; ++q)
11102 {
11103 int32_t hmr;
11104
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!p_igetl(&hmr,f,keepdata))
11105 return qe_invalid;
11106
11107
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(keepdata)
11108 {
11109 12 hammeroffsets[q] = hmr;
11110 12 }
11111 12 }
11112 3 }
11113 else if (keepdata)
11114 {
11115 for(int32_t q = 0; q < 4; ++q) hammeroffsets[q] = 0;
11116 }
11117
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if (v_herosprites > 11)
11118 {
11119
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 3 times.
12 for(int32_t q = 0; q < 3; ++q)
11120 {
11121
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_igetl(&tile,f,keepdata))
11122 return qe_invalid;
11123
11124
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(!p_getc(&flip,f,keepdata))
11125 return qe_invalid;
11126
11127
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(!p_getc(&extend,f,keepdata))
11128 return qe_invalid;
11129
11130
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(keepdata)
11131 {
11132 9 setSprite(sideswimholdspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11133 9 }
11134 9 }
11135 3 }
11136 else if (keepdata)
11137 {
11138 memset(sideswimholdspr, 0, sizeof(sideswimholdspr));
11139 }
11140
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if (v_herosprites > 12)
11141 {
11142
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_igetl(&tile,f,keepdata))
11143 return qe_invalid;
11144
11145
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_getc(&flip,f,keepdata))
11146 return qe_invalid;
11147
11148
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_getc(&extend,f,keepdata))
11149 return qe_invalid;
11150
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if (keepdata)
11151 {
11152 3 setSprite(sideswimcastingspr, int32_t(tile), int32_t(flip), int32_t(extend));
11153 3 }
11154
11155 3 }
11156 else if (keepdata)
11157 {
11158 memset(sideswimcastingspr, 0, sizeof(sideswimcastingspr));
11159 }
11160
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if (v_herosprites > 13)
11161 {
11162
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 3 times.
15 for(int32_t q = 0; q < 4; ++q)
11163 {
11164
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetl(&tile,f,keepdata))
11165 return qe_invalid;
11166
11167
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!p_getc(&flip,f,keepdata))
11168 return qe_invalid;
11169
11170
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!p_getc(&extend,f,keepdata))
11171 return qe_invalid;
11172
11173
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(keepdata)
11174 {
11175 12 setSprite(sidedrowningspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11176 12 }
11177 12 }
11178 3 }
11179 else if (keepdata)
11180 {
11181 memset(sidedrowningspr, 0, sizeof(sidedrowningspr));
11182 }
11183
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if (v_herosprites > 14)
11184 {
11185
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 3 times.
15 for(int32_t q = 0; q < 4; ++q)
11186 {
11187
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetl(&tile,f,keepdata))
11188 return qe_invalid;
11189
11190
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!p_getc(&flip,f,keepdata))
11191 return qe_invalid;
11192
11193
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!p_getc(&extend,f,keepdata))
11194 return qe_invalid;
11195
11196
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(keepdata)
11197 {
11198 12 setSprite(revslashspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11199 12 }
11200 12 }
11201 3 }
11202 else if (keepdata)
11203 {
11204 memset(revslashspr, 0, sizeof(revslashspr));
11205 }
11206
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if (v_herosprites > 7)
11207 {
11208 3 int32_t num_defense = wMax;
11209 3 byte def = 0;
11210
11211 //Set num_defense accordingly if changes to enum require version upgrade - Jman
11212 /*if(v_herosprites > [x])
11213 * {
11214 * num_defense = 146 //value of wMax on version 8
11215 * }
11216 */
11217
11218
2/2
✓ Branch 0 taken 438 times.
✓ Branch 1 taken 3 times.
441 for (int32_t q = 0; q < num_defense; q++)
11219 {
11220
1/2
✓ Branch 0 taken 438 times.
✗ Branch 1 not taken.
438 if (!p_getc(&def, f, keepdata))
11221 return qe_invalid;
11222
11223
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 438 times.
438 if (keepdata)
11224 {
11225 438 hero_defence[q] = def;
11226 438 }
11227 438 }
11228 3 }
11229 else if (keepdata)
11230 {
11231 int32_t num_defense = wMax;
11232 for (int32_t q = 0; q < num_defense; q++)
11233 {
11234 hero_defence[q] = 0;
11235 }
11236 }
11237 3 }
11238
11239 3 return 0;
11240 3 }
11241
11242
11243 58 int32_t readherosprites(PACKFILE *f, zquestheader *Header, bool keepdata)
11244 {
11245 //these are here to bypass compiler warnings about unused arguments
11246 58 Header=Header;
11247
11248 dword dummy;
11249 58 word s_version=0, s_cversion=0;
11250
11251 //section version info
11252
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 if(!p_igetw(&s_version,f,true))
11253 {
11254 return qe_invalid;
11255 }
11256
11257 58 FFCore.quest_format[vHeroSprites] = s_version;
11258
11259 //al_trace("Player sprites version %d\n", s_version);
11260
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(!p_igetw(&s_cversion,f,true))
11261 {
11262 return qe_invalid;
11263 }
11264
11265 //section size
11266
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(!p_igetl(&dummy,f,true))
11267 {
11268 return qe_invalid;
11269 }
11270
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 55 times.
58 if ( s_version >= 6 )
11271 {
11272 //al_trace("Reading Player Sprites v6\n");
11273 3 return readherosprites3(f, s_version, dummy, keepdata);
11274 }
11275 55 else return readherosprites2(f, s_version, dummy, keepdata);
11276 58 }
11277
11278 58 int32_t readsubscreens(PACKFILE *f, zquestheader *Header, bool keepdata)
11279 {
11280 int32_t dummy;
11281 58 word s_version=0, s_cversion=0;
11282
11283 //section version info
11284
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 if(!p_igetw(&s_version,f,true))
11285 {
11286 return qe_invalid;
11287 }
11288
11289 58 FFCore.quest_format[vSubscreen] = s_version;
11290
11291 //al_trace("Subscreens version %d\n", s_version);
11292
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(!p_igetw(&s_cversion,f,true))
11293 {
11294 return qe_invalid;
11295 }
11296
11297 //section size
11298
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(!p_igetl(&dummy,f,true))
11299 {
11300 return qe_invalid;
11301 }
11302
11303 //finally... section data
11304
2/2
✓ Branch 0 taken 7424 times.
✓ Branch 1 taken 58 times.
7482 for(int32_t i=0; i<MAXCUSTOMSUBSCREENS; i++)
11305 {
11306 7424 int32_t ret = read_one_subscreen(f, Header, keepdata, i, s_version, s_cversion);
11307
11308
1/2
✓ Branch 0 taken 7424 times.
✗ Branch 1 not taken.
7424 if(ret!=0) return ret;
11309 7424 }
11310
11311 58 return 0;
11312 58 }
11313
11314 7424 int32_t read_one_subscreen(PACKFILE *f, zquestheader *, bool keepdata, int32_t i, word s_version, word)
11315 {
11316 7424 int32_t numsub=0;
11317 7424 byte temp_ss=0;
11318 subscreen_object temp_sub_stack;
11319 7424 subscreen_object *temp_sub = &temp_sub_stack;
11320
11321 char tempname[64];
11322
11323
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7424 times.
7424 if(!pfread(tempname,64,f,true))
11324 {
11325 return qe_invalid;
11326 }
11327
11328
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7424 times.
7424 if(s_version > 1)
11329 {
11330
1/2
✓ Branch 0 taken 7424 times.
✗ Branch 1 not taken.
7424 if(!p_getc(&temp_ss,f,keepdata))
11331 {
11332 return qe_invalid;
11333 }
11334 7424 }
11335
11336
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7424 times.
7424 if(s_version < 4)
11337 {
11338 uint8_t tmp=0;
11339
11340 if(!p_getc(&tmp,f,true))
11341 {
11342 return qe_invalid;
11343 }
11344
11345 numsub = (int32_t)tmp;
11346 }
11347 else
11348 {
11349 word tmp;
11350
11351
1/2
✓ Branch 0 taken 7424 times.
✗ Branch 1 not taken.
7424 if(!p_igetw(&tmp, f, true))
11352 {
11353 return qe_invalid;
11354 }
11355
11356 7424 numsub = (int32_t)tmp;
11357 }
11358
11359 int32_t j;
11360
11361
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 14342 times.
✓ Branch 2 taken 6918 times.
✓ Branch 3 taken 7424 times.
14342 for(j=0; (j<MAXSUBSCREENITEMS&&j<numsub); j++)
11362 {
11363
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6918 times.
6918 if(keepdata)
11364 {
11365 6918 memset(temp_sub,0,sizeof(subscreen_object));
11366
11367
2/2
✓ Branch 0 taken 830 times.
✓ Branch 1 taken 6088 times.
6918 switch(custom_subscreen[i].objects[j].type)
11368 {
11369 case ssoTEXT:
11370 case ssoTEXTBOX:
11371 case ssoCURRENTITEMTEXT:
11372 case ssoCURRENTITEMCLASSTEXT:
11373
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 830 times.
✓ Branch 2 taken 830 times.
✗ Branch 3 not taken.
830 if(custom_subscreen[i].objects[j].dp1 != NULL) delete [](char *)custom_subscreen[i].objects[j].dp1;
11374
11375 //fall through
11376 default:
11377 6918 memset(&custom_subscreen[i].objects[j],0,sizeof(subscreen_object));
11378 6918 break;
11379 }
11380 6918 }
11381
11382
1/2
✓ Branch 0 taken 6918 times.
✗ Branch 1 not taken.
6918 if(!p_getc(&(temp_sub->type),f,true))
11383 {
11384 return qe_invalid;
11385 }
11386
11387
1/2
✓ Branch 0 taken 6918 times.
✗ Branch 1 not taken.
6918 if(!p_getc(&(temp_sub->pos),f,keepdata))
11388 {
11389 return qe_invalid;
11390 }
11391
11392
1/2
✓ Branch 0 taken 6918 times.
✗ Branch 1 not taken.
6918 if(s_version < 5)
11393 {
11394 switch(temp_sub->pos)
11395 {
11396 case 0:
11397 temp_sub->pos = sspUP | sspDOWN | sspSCROLLING;
11398 break;
11399
11400 case 1:
11401 temp_sub->pos = sspUP;
11402 break;
11403
11404 case 2:
11405 temp_sub->pos = sspDOWN;
11406 break;
11407
11408 default:
11409 temp_sub->pos = 0;
11410 }
11411 }
11412
11413
1/2
✓ Branch 0 taken 6918 times.
✗ Branch 1 not taken.
6918 if(!p_igetw(&(temp_sub->x),f,keepdata))
11414 {
11415 return qe_invalid;
11416 }
11417
11418
1/2
✓ Branch 0 taken 6918 times.
✗ Branch 1 not taken.
6918 if(!p_igetw(&(temp_sub->y),f,keepdata))
11419 {
11420 return qe_invalid;
11421 }
11422
11423
1/2
✓ Branch 0 taken 6918 times.
✗ Branch 1 not taken.
6918 if(!p_igetw(&(temp_sub->w),f,keepdata))
11424 {
11425 return qe_invalid;
11426 }
11427
11428
1/2
✓ Branch 0 taken 6918 times.
✗ Branch 1 not taken.
6918 if(!p_igetw(&(temp_sub->h),f,keepdata))
11429 {
11430 return qe_invalid;
11431 }
11432
11433
1/2
✓ Branch 0 taken 6918 times.
✗ Branch 1 not taken.
6918 if(!p_getc(&(temp_sub->colortype1),f,keepdata))
11434 {
11435 return qe_invalid;
11436 }
11437
11438
1/2
✓ Branch 0 taken 6918 times.
✗ Branch 1 not taken.
6918 if(!p_igetw(&(temp_sub->color1),f,keepdata))
11439 {
11440 return qe_invalid;
11441 }
11442
11443
1/2
✓ Branch 0 taken 6918 times.
✗ Branch 1 not taken.
6918 if(!p_getc(&(temp_sub->colortype2),f,keepdata))
11444 {
11445 return qe_invalid;
11446 }
11447
11448
1/2
✓ Branch 0 taken 6918 times.
✗ Branch 1 not taken.
6918 if(!p_igetw(&(temp_sub->color2),f,keepdata))
11449 {
11450 return qe_invalid;
11451 }
11452
11453
1/2
✓ Branch 0 taken 6918 times.
✗ Branch 1 not taken.
6918 if(!p_getc(&(temp_sub->colortype3),f,keepdata))
11454 {
11455 return qe_invalid;
11456 }
11457
11458
1/2
✓ Branch 0 taken 6918 times.
✗ Branch 1 not taken.
6918 if(!p_igetw(&(temp_sub->color3),f,keepdata))
11459 {
11460 return qe_invalid;
11461 }
11462
11463
1/2
✓ Branch 0 taken 6918 times.
✗ Branch 1 not taken.
6918 if(!p_igetd(&(temp_sub->d1),f,keepdata))
11464 {
11465 return qe_invalid;
11466 }
11467
11468
1/2
✓ Branch 0 taken 6918 times.
✗ Branch 1 not taken.
6918 if(!p_igetd(&(temp_sub->d2),f,keepdata))
11469 {
11470 return qe_invalid;
11471 }
11472
11473
1/2
✓ Branch 0 taken 6918 times.
✗ Branch 1 not taken.
6918 if(!p_igetd(&(temp_sub->d3),f,keepdata))
11474 {
11475 return qe_invalid;
11476 }
11477
11478
1/2
✓ Branch 0 taken 6918 times.
✗ Branch 1 not taken.
6918 if(!p_igetd(&(temp_sub->d4),f,keepdata))
11479 {
11480 return qe_invalid;
11481 }
11482
11483
1/2
✓ Branch 0 taken 6918 times.
✗ Branch 1 not taken.
6918 if(!p_igetd(&(temp_sub->d5),f,keepdata))
11484 {
11485 return qe_invalid;
11486 }
11487
11488
1/2
✓ Branch 0 taken 6918 times.
✗ Branch 1 not taken.
6918 if(!p_igetd(&(temp_sub->d6),f,keepdata))
11489 {
11490 return qe_invalid;
11491 }
11492
11493
1/2
✓ Branch 0 taken 6918 times.
✗ Branch 1 not taken.
6918 if(!p_igetd(&(temp_sub->d7),f,keepdata))
11494 {
11495 return qe_invalid;
11496 }
11497
11498
1/2
✓ Branch 0 taken 6918 times.
✗ Branch 1 not taken.
6918 if(!p_igetd(&(temp_sub->d8),f,keepdata))
11499 {
11500 return qe_invalid;
11501 }
11502
11503
1/2
✓ Branch 0 taken 6918 times.
✗ Branch 1 not taken.
6918 if(!p_igetd(&(temp_sub->d9),f,keepdata))
11504 {
11505 return qe_invalid;
11506 }
11507
11508
1/2
✓ Branch 0 taken 6918 times.
✗ Branch 1 not taken.
6918 if(!p_igetd(&(temp_sub->d10),f,keepdata))
11509 {
11510 return qe_invalid;
11511 }
11512
11513
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6918 times.
6918 if(s_version < 2)
11514 {
11515 if(!p_igetl(&(temp_sub->speed),f,keepdata))
11516 {
11517 return qe_invalid;
11518 }
11519
11520 if(!p_igetl(&(temp_sub->delay),f,keepdata))
11521 {
11522 return qe_invalid;
11523 }
11524
11525 if(!p_igetl(&(temp_sub->frame),f,keepdata))
11526 {
11527 return qe_invalid;
11528 }
11529 }
11530 else
11531 {
11532
1/2
✓ Branch 0 taken 6918 times.
✗ Branch 1 not taken.
6918 if(!p_getc(&(temp_sub->speed),f,keepdata))
11533 {
11534 return qe_invalid;
11535 }
11536
11537
1/2
✓ Branch 0 taken 6918 times.
✗ Branch 1 not taken.
6918 if(!p_getc(&(temp_sub->delay),f,keepdata))
11538 {
11539 return qe_invalid;
11540 }
11541
11542
1/2
✓ Branch 0 taken 6918 times.
✗ Branch 1 not taken.
6918 if(!p_igetw(&(temp_sub->frame),f,keepdata))
11543 {
11544 return qe_invalid;
11545 }
11546 }
11547
11548 6918 int32_t temp_size=0;
11549
11550 // bool deletets = false;
11551
4/4
✓ Branch 0 taken 3051 times.
✓ Branch 1 taken 927 times.
✓ Branch 2 taken 2830 times.
✓ Branch 3 taken 110 times.
6918 switch(temp_sub->type)
11552 {
11553 case ssoTEXT:
11554 case ssoTEXTBOX:
11555 case ssoCURRENTITEMTEXT:
11556 case ssoCURRENTITEMCLASSTEXT:
11557 word temptempsize;
11558 /*uint8_t temp1;
11559 uint8_t temp2;
11560 temp2 = 0;
11561 if(!p_getc(&temp1,f,true))
11562 {
11563 return qe_invalid;
11564 }
11565 if(temp1)
11566 {
11567
11568 if(!p_getc(&temp2,f,true))
11569 {
11570 return qe_invalid;
11571 }
11572 }*/
11573
11574
1/2
✓ Branch 0 taken 927 times.
✗ Branch 1 not taken.
927 if(!p_igetw(&temptempsize,f,true))
11575 {
11576 return qe_invalid;
11577 }
11578
11579 //temptempsize = temp1 + (temp2 << 8);
11580 927 temp_size = (int32_t)temptempsize;
11581
11582 //if(temp_sub->dp1!=NULL) delete[] temp_sub->dp1;
11583
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 927 times.
927 if(keepdata)
11584 {
11585 927 uint32_t char_length = temp_size+1;
11586 927 temp_sub->dp1 = new char[char_length]; //memory not freed
11587
11588 //deletets = true; //obsolete
11589 927 }
11590
11591
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 927 times.
927 if(temp_size)
11592 {
11593
1/2
✓ Branch 0 taken 927 times.
✗ Branch 1 not taken.
927 if(!pfread(temp_sub->dp1,temp_size+1,f,keepdata))
11594 {
11595 return qe_invalid;
11596 }
11597 927 }
11598
11599 927 break;
11600
11601 case ssoLIFEMETER:
11602
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(get_bit(deprecated_rules, 12) != 0) // qr_24HC
11603 temp_sub->d3 = 1;
11604
11605
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!p_getc(&(temp_sub->dp1),f,keepdata))
11606 {
11607 return qe_invalid;
11608 }
11609
11610 110 break;
11611
11612
11613 case ssoCURRENTITEM:
11614
11615
1/2
✓ Branch 0 taken 3051 times.
✗ Branch 1 not taken.
3051 if(s_version < 6)
11616 {
11617 switch(temp_sub->d1)
11618 {
11619 case ssiBOMB:
11620 temp_sub->d1 = itype_bomb;
11621 break;
11622
11623 case ssiSWORD:
11624 temp_sub->d1 = itype_sword;
11625 break;
11626
11627 case ssiSHIELD:
11628 temp_sub->d1 = itype_shield;
11629 break;
11630
11631 case ssiCANDLE:
11632 temp_sub->d1 = itype_candle;
11633 break;
11634
11635 case ssiLETTER:
11636 temp_sub->d1 = itype_letter;
11637 break;
11638
11639 case ssiPOTION:
11640 temp_sub->d1 = itype_potion;
11641 break;
11642
11643 case ssiLETTERPOTION:
11644 temp_sub->d1 = itype_letterpotion;
11645 break;
11646
11647 case ssiBOW:
11648 temp_sub->d1 = itype_bow;
11649 break;
11650
11651 case ssiARROW:
11652 temp_sub->d1 = itype_arrow;
11653 break;
11654
11655 case ssiBOWANDARROW:
11656 temp_sub->d1 = itype_bowandarrow;
11657 break;
11658
11659 case ssiBAIT:
11660 temp_sub->d1 = itype_bait;
11661 break;
11662
11663 case ssiRING:
11664 temp_sub->d1 = itype_ring;
11665 break;
11666
11667 case ssiBRACELET:
11668 temp_sub->d1 = itype_bracelet;
11669 break;
11670
11671 case ssiMAP:
11672 temp_sub->d1 = itype_map;
11673 break;
11674
11675 case ssiCOMPASS:
11676 temp_sub->d1 = itype_compass;
11677 break;
11678
11679 case ssiBOSSKEY:
11680 temp_sub->d1 = itype_bosskey;
11681 break;
11682
11683 case ssiMAGICKEY:
11684 temp_sub->d1 = itype_magickey;
11685 break;
11686
11687 case ssiBRANG:
11688 temp_sub->d1 = itype_brang;
11689 break;
11690
11691 case ssiWAND:
11692 temp_sub->d1 = itype_wand;
11693 break;
11694
11695 case ssiRAFT:
11696 temp_sub->d1 = itype_raft;
11697 break;
11698
11699 case ssiLADDER:
11700 temp_sub->d1 = itype_ladder;
11701 break;
11702
11703 case ssiWHISTLE:
11704 temp_sub->d1 = itype_whistle;
11705 break;
11706
11707 case ssiBOOK:
11708 temp_sub->d1 = itype_book;
11709 break;
11710
11711 case ssiWALLET:
11712 temp_sub->d1 = itype_wallet;
11713 break;
11714
11715 case ssiSBOMB:
11716 temp_sub->d1 = itype_sbomb;
11717 break;
11718
11719 case ssiHCPIECE:
11720 temp_sub->d1 = itype_heartpiece;
11721 break;
11722
11723 case ssiAMULET:
11724 temp_sub->d1 = itype_amulet;
11725 break;
11726
11727 case ssiFLIPPERS:
11728 temp_sub->d1 = itype_flippers;
11729 break;
11730
11731 case ssiHOOKSHOT:
11732 temp_sub->d1 = itype_hookshot;
11733 break;
11734
11735 case ssiLENS:
11736 temp_sub->d1 = itype_lens;
11737 break;
11738
11739 case ssiHAMMER:
11740 temp_sub->d1 = itype_hammer;
11741 break;
11742
11743 case ssiBOOTS:
11744 temp_sub->d1 = itype_boots;
11745 break;
11746
11747 case ssiDINSFIRE:
11748 temp_sub->d1 = itype_dinsfire;
11749 break;
11750
11751 case ssiFARORESWIND:
11752 temp_sub->d1 = itype_faroreswind;
11753 break;
11754
11755 case ssiNAYRUSLOVE:
11756 temp_sub->d1 = itype_nayruslove;
11757 break;
11758
11759 case ssiQUIVER:
11760 temp_sub->d1 = itype_quiver;
11761 break;
11762
11763 case ssiBOMBBAG:
11764 temp_sub->d1 = itype_bombbag;
11765 break;
11766
11767 case ssiCBYRNA:
11768 temp_sub->d1 = itype_cbyrna;
11769 break;
11770
11771 case ssiROCS:
11772 temp_sub->d1 = itype_rocs;
11773 break;
11774
11775 case ssiHOVERBOOTS:
11776 temp_sub->d1 = itype_hoverboots;
11777 break;
11778
11779 case ssiSPINSCROLL:
11780 temp_sub->d1 = itype_spinscroll;
11781 break;
11782
11783 case ssiCROSSSCROLL:
11784 temp_sub->d1 = itype_crossscroll;
11785 break;
11786
11787 case ssiQUAKESCROLL:
11788 temp_sub->d1 = itype_quakescroll;
11789 break;
11790
11791 case ssiWHISPRING:
11792 temp_sub->d1 = itype_whispring;
11793 break;
11794
11795 case ssiCHARGERING:
11796 temp_sub->d1 = itype_chargering;
11797 break;
11798
11799 case ssiPERILSCROLL:
11800 temp_sub->d1 = itype_perilscroll;
11801 break;
11802
11803 case ssiWEALTHMEDAL:
11804 temp_sub->d1 = itype_wealthmedal;
11805 break;
11806
11807 case ssiHEARTRING:
11808 temp_sub->d1 = itype_heartring;
11809 break;
11810
11811 case ssiMAGICRING:
11812 temp_sub->d1 = itype_magicring;
11813 break;
11814
11815 case ssiSPINSCROLL2:
11816 temp_sub->d1 = itype_spinscroll2;
11817 break;
11818
11819 case ssiQUAKESCROLL2:
11820 temp_sub->d1 = itype_quakescroll2;
11821 break;
11822
11823 case ssiAGONY:
11824 temp_sub->d1 = itype_agony;
11825 break;
11826
11827 case ssiSTOMPBOOTS:
11828 temp_sub->d1 = itype_stompboots;
11829 break;
11830
11831 case ssiWHIMSICALRING:
11832 temp_sub->d1 = itype_whimsicalring;
11833 break;
11834
11835 case ssiPERILRING:
11836 temp_sub->d1 = itype_perilring;
11837 break;
11838
11839 default:
11840 temp_sub->d1 += itype_custom1 - ssiMAX;
11841 }
11842 }
11843
11844 //fall-through
11845 default:
11846
1/2
✓ Branch 0 taken 5881 times.
✗ Branch 1 not taken.
5881 if(!p_getc(&(temp_sub->dp1),f,keepdata))
11847 {
11848 return qe_invalid;
11849 }
11850
11851 5881 break;
11852 }
11853
11854
2/2
✓ Branch 0 taken 1629 times.
✓ Branch 1 taken 5289 times.
6918 if(s_version < 7)
11855 {
11856
1/3
✓ Branch 0 taken 5289 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
5289 switch(temp_sub->type)
11857 {
11858 case ssoMAGICGAUGE:
11859 {
11860 if(!temp_sub->d9)
11861 temp_sub->d9 = -1; //-1 now represents 'always'
11862 break;
11863 }
11864 case ssoLIFEGAUGE:
11865 temp_sub->d9 = 0; //Unused, doesn't do anything? Clear it...
11866 break;
11867 }
11868 5289 }
11869
11870
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6918 times.
6918 if(keepdata)
11871 {
11872
3/3
✓ Branch 0 taken 927 times.
✓ Branch 1 taken 5797 times.
✓ Branch 2 taken 194 times.
6918 switch(temp_sub->type)
11873 {
11874 case ssoTEXT:
11875 case ssoTEXTBOX:
11876 case ssoCURRENTITEMTEXT:
11877 case ssoCURRENTITEMCLASSTEXT:
11878
1/4
✓ Branch 0 taken 927 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
927 if(custom_subscreen[i].objects[j].dp1 != NULL) delete[](char *)custom_subscreen[i].objects[j].dp1;
11879
11880 927 memcpy(&custom_subscreen[i].objects[j],temp_sub,sizeof(subscreen_object));
11881 927 custom_subscreen[i].objects[j].dp1 = NULL;
11882 927 custom_subscreen[i].objects[j].dp1 = new char[temp_size+1];
11883 927 strcpy((char*)custom_subscreen[i].objects[j].dp1,(char*)temp_sub->dp1);
11884 927 break;
11885
11886 case ssoCOUNTER:
11887
1/2
✓ Branch 0 taken 194 times.
✗ Branch 1 not taken.
194 if(s_version<3)
11888 {
11889 temp_sub->d6=(temp_sub->d6?1:0)+(temp_sub->d8?2:0);
11890 temp_sub->d8=0;
11891 }
11892
11893 default:
11894 5991 memcpy(&custom_subscreen[i].objects[j],temp_sub,sizeof(subscreen_object));
11895 5991 break;
11896 }
11897
11898 6918 strcpy(custom_subscreen[i].name, tempname);
11899 6918 custom_subscreen[i].ss_type = temp_ss;
11900 6918 }
11901 6918 }
11902
11903
2/2
✓ Branch 0 taken 1893626 times.
✓ Branch 1 taken 7424 times.
1901050 for(j=numsub; j<MAXSUBSCREENITEMS; j++)
11904 {
11905
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1893626 times.
1893626 if(keepdata)
11906 {
11907 //clear all unused object in this subscreen -DD
11908
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1893626 times.
1893626 switch(custom_subscreen[i].objects[j].type)
11909 {
11910 case ssoTEXT:
11911 case ssoTEXTBOX:
11912 case ssoCURRENTITEMTEXT:
11913 case ssoCURRENTITEMCLASSTEXT:
11914 if(custom_subscreen[i].objects[j].dp1 != NULL) delete [](char *)custom_subscreen[i].objects[j].dp1;
11915
11916 //fall through
11917 default:
11918 1893626 memset(&custom_subscreen[i].objects[j],0,sizeof(subscreen_object));
11919 1893626 break;
11920 }
11921 1893626 }
11922 1893626 }
11923
11924 7424 return 0;
11925 7424 }
11926
11927 1152 void reset_subscreen(subscreen_group *tempss)
11928 {
11929
2/2
✓ Branch 0 taken 294912 times.
✓ Branch 1 taken 1152 times.
296064 for(int32_t i=0; i<MAXSUBSCREENITEMS; ++i)
11930 {
11931
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 294853 times.
294912 switch(tempss->objects[i].type)
11932 {
11933 case ssoTEXT:
11934 case ssoTEXTBOX:
11935 case ssoCURRENTITEMTEXT:
11936 case ssoCURRENTITEMCLASSTEXT:
11937
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 59 times.
✓ Branch 2 taken 59 times.
✗ Branch 3 not taken.
59 if(tempss->objects[i].dp1 != NULL) delete [](char *)tempss->objects[i].dp1;
11938
11939 //fall through
11940 default:
11941 294912 memset(&tempss->objects[i],0,sizeof(subscreen_object));
11942 294912 break;
11943 }
11944 294912 }
11945 1152 }
11946
11947 9 void reset_subscreens()
11948 {
11949
2/2
✓ Branch 0 taken 1152 times.
✓ Branch 1 taken 9 times.
1161 for(int32_t i=0; i<MAXCUSTOMSUBSCREENS; ++i)
11950 {
11951 1152 reset_subscreen(&custom_subscreen[i]);
11952 1152 }
11953 9 }
11954
11955 9 int32_t setupsubscreens()
11956 {
11957 9 reset_subscreens();
11958 9 int32_t tempsubscreen=zinit.subscreen;
11959 subscreen_object *tempsub;
11960
11961
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(tempsubscreen>=ssdtMAX)
11962 {
11963 tempsubscreen=0;
11964 }
11965
11966
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
9 switch(tempsubscreen)
11967 {
11968 case ssdtOLD:
11969 case ssdtNEWSUBSCR:
11970 case ssdtREV2:
11971 case ssdtBSZELDA:
11972 case ssdtBSZELDAMODIFIED:
11973 case ssdtBSZELDAENHANCED:
11974 case ssdtBSZELDACOMPLETE:
11975 {
11976 9 tempsub = default_subscreen_active[tempsubscreen][0];
11977 int32_t i;
11978
11979
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 594 times.
✓ Branch 2 taken 585 times.
✓ Branch 3 taken 9 times.
594 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
11980 {
11981
2/3
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 559 times.
✗ Branch 2 not taken.
585 switch(tempsub[i].type)
11982 {
11983 case ssoTEXT:
11984 case ssoTEXTBOX:
11985 case ssoCURRENTITEMTEXT:
11986 case ssoCURRENTITEMCLASSTEXT:
11987
1/4
✓ Branch 0 taken 26 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
26 if(custom_subscreen[0].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[0].objects[i].dp1;
11988
11989 26 memcpy(&custom_subscreen[0].objects[i],&tempsub[i],sizeof(subscreen_object));
11990 26 custom_subscreen[0].objects[i].dp1 = NULL;
11991 26 custom_subscreen[0].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
11992 26 strcpy((char*)custom_subscreen[0].objects[i].dp1,(char*)tempsub[i].dp1);
11993 26 break;
11994
11995 case ssoLIFEMETER:
11996 {
11997 memcpy(&custom_subscreen[0].objects[i],&tempsub[i],sizeof(subscreen_object));
11998
11999 if(get_bit(deprecated_rules, 12) != 0)
12000 custom_subscreen[0].objects[i].d3=1;
12001 else
12002 custom_subscreen[0].objects[i].d3=0;
12003
12004 break;
12005 }
12006 /*
12007 case ssoTRIFRAME:
12008 {
12009 memcpy(&custom_subscreen[0].objects[i],&tempsub[i],sizeof(subscreen_object));
12010 custom_subscreen[0].objects[i].d1 = 8594;
12011 custom_subscreen[0].objects[i].d2 = 8;
12012 custom_subscreen[0].objects[i].d3 = 8771;
12013 custom_subscreen[0].objects[i].d4 = 8;
12014 custom_subscreen[0].objects[i].d5 = 1;
12015 custom_subscreen[0].objects[i].d6 = 1;
12016 break;
12017 }*/
12018
12019 default:
12020 559 memcpy(&custom_subscreen[0].objects[i],&tempsub[i],sizeof(subscreen_object));
12021 559 break;
12022 }
12023 585 }
12024
12025 9 custom_subscreen[0].ss_type=sstACTIVE;
12026 9 sprintf(custom_subscreen[0].name, "Active Subscreen (Triforce)");
12027 9 tempsub = default_subscreen_active[tempsubscreen][1];
12028
12029
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 594 times.
✓ Branch 2 taken 585 times.
✓ Branch 3 taken 9 times.
594 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12030 {
12031
2/3
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 550 times.
✗ Branch 2 not taken.
585 switch(tempsub[i].type)
12032 {
12033 case ssoTEXT:
12034 case ssoTEXTBOX:
12035 case ssoCURRENTITEMTEXT:
12036 case ssoCURRENTITEMCLASSTEXT:
12037
1/4
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
35 if(custom_subscreen[1].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[1].objects[i].dp1;
12038
12039 35 memcpy(&custom_subscreen[1].objects[i],&tempsub[i],sizeof(subscreen_object));
12040 35 custom_subscreen[1].objects[i].dp1 = NULL;
12041 35 custom_subscreen[1].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12042 35 strcpy((char*)custom_subscreen[1].objects[i].dp1,(char*)tempsub[i].dp1);
12043 35 break;
12044
12045 case ssoLIFEMETER:
12046 {
12047 memcpy(&custom_subscreen[1].objects[i],&tempsub[i],sizeof(subscreen_object));
12048
12049 if(get_bit(deprecated_rules, 12) != 0)
12050 custom_subscreen[1].objects[i].d3=1;
12051 else
12052 custom_subscreen[1].objects[i].d3=0;
12053
12054 break;
12055 }
12056 /*
12057 case ssoTRIFRAME:
12058 {
12059 custom_subscreen[1].objects[i].d1 = 8594;
12060 custom_subscreen[1].objects[i].d2 = 8;
12061 custom_subscreen[1].objects[i].d3 = 8771;
12062 custom_subscreen[1].objects[i].d4 = 8;
12063 custom_subscreen[1].objects[i].d5 = 1;
12064 custom_subscreen[1].objects[i].d6 = 1;
12065 break;
12066 }*/
12067
12068 default:
12069 550 memcpy(&custom_subscreen[1].objects[i],&tempsub[i],sizeof(subscreen_object));
12070 550 break;
12071 }
12072 585 }
12073
12074 9 custom_subscreen[1].ss_type=sstACTIVE;
12075 9 sprintf(custom_subscreen[1].name, "Active Subscreen (Dungeon Map)");
12076 // memset(&custom_subscreen[1].objects[i],0,sizeof(subscreen_object));
12077 9 tempsub = default_subscreen_passive[tempsubscreen][0];
12078
12079
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 189 times.
✓ Branch 2 taken 180 times.
✓ Branch 3 taken 9 times.
189 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12080 {
12081
3/3
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 144 times.
✓ Branch 2 taken 9 times.
180 switch(tempsub[i].type)
12082 {
12083 case ssoTEXT:
12084 case ssoTEXTBOX:
12085 case ssoCURRENTITEMTEXT:
12086 case ssoCURRENTITEMCLASSTEXT:
12087
1/4
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
27 if(custom_subscreen[2].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[2].objects[i].dp1;
12088
12089 27 memcpy(&custom_subscreen[2].objects[i],&tempsub[i],sizeof(subscreen_object));
12090 27 custom_subscreen[2].objects[i].dp1 = NULL;
12091 27 custom_subscreen[2].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12092 27 strcpy((char*)custom_subscreen[2].objects[i].dp1,(char*)tempsub[i].dp1);
12093 27 break;
12094
12095 case ssoLIFEMETER:
12096 {
12097 9 memcpy(&custom_subscreen[2].objects[i],&tempsub[i],sizeof(subscreen_object));
12098
12099
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(get_bit(deprecated_rules, 12) != 0)
12100 custom_subscreen[2].objects[i].d3=1;
12101 else
12102 9 custom_subscreen[2].objects[i].d3=0;
12103
12104 9 break;
12105 }
12106
12107 default:
12108 144 memcpy(&custom_subscreen[2].objects[i],&tempsub[i],sizeof(subscreen_object));
12109 144 break;
12110 }
12111 180 }
12112
12113 9 custom_subscreen[2].ss_type=sstPASSIVE;
12114 9 sprintf(custom_subscreen[2].name, "Passive Subscreen (Magic)");
12115 // memset(&custom_subscreen[2].objects[i],0,sizeof(subscreen_object));
12116 9 tempsub = default_subscreen_passive[tempsubscreen][1];
12117
12118
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 180 times.
✓ Branch 2 taken 171 times.
✓ Branch 3 taken 9 times.
180 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12119 {
12120
3/3
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 135 times.
✓ Branch 2 taken 9 times.
171 switch(tempsub[i].type)
12121 {
12122 case ssoTEXT:
12123 case ssoTEXTBOX:
12124 case ssoCURRENTITEMTEXT:
12125 case ssoCURRENTITEMCLASSTEXT:
12126
1/4
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
27 if(custom_subscreen[3].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[3].objects[i].dp1;
12127
12128 27 memcpy(&custom_subscreen[3].objects[i],&tempsub[i],sizeof(subscreen_object));
12129 27 custom_subscreen[3].objects[i].dp1 = NULL;
12130 27 custom_subscreen[3].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12131 27 strcpy((char*)custom_subscreen[3].objects[i].dp1,(char*)tempsub[i].dp1);
12132 27 break;
12133
12134 case ssoLIFEMETER:
12135 {
12136 9 memcpy(&custom_subscreen[3].objects[i],&tempsub[i],sizeof(subscreen_object));
12137
12138
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(get_bit(deprecated_rules, 12) != 0)
12139 custom_subscreen[3].objects[i].d3=1;
12140 else
12141 9 custom_subscreen[3].objects[i].d3=0;
12142
12143 9 break;
12144 }
12145
12146 default:
12147 135 memcpy(&custom_subscreen[3].objects[i],&tempsub[i],sizeof(subscreen_object));
12148 135 break;
12149 }
12150 171 }
12151
12152 9 custom_subscreen[3].ss_type=sstPASSIVE;
12153 9 sprintf(custom_subscreen[3].name, "Passive Subscreen (No Magic)");
12154 // memset(&custom_subscreen[3].objects[i],0,sizeof(subscreen_object));
12155 9 break;
12156 }
12157
12158 case ssdtZ3:
12159 {
12160 tempsub = z3_active_a;
12161 int32_t i;
12162
12163 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12164 {
12165 switch(tempsub[i].type)
12166 {
12167 case ssoTEXT:
12168 case ssoTEXTBOX:
12169 case ssoCURRENTITEMTEXT:
12170 case ssoCURRENTITEMCLASSTEXT:
12171 if(custom_subscreen[0].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[0].objects[i].dp1;
12172
12173 memcpy(&custom_subscreen[0].objects[i],&tempsub[i],sizeof(subscreen_object));
12174 custom_subscreen[0].objects[i].dp1 = NULL;
12175 custom_subscreen[0].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12176 strcpy((char*)custom_subscreen[0].objects[i].dp1,(char*)tempsub[i].dp1);
12177 break;
12178
12179 case ssoLIFEMETER:
12180 {
12181 memcpy(&custom_subscreen[0].objects[i],&tempsub[i],sizeof(subscreen_object));
12182
12183 if(get_bit(deprecated_rules, 12) != 0)
12184 custom_subscreen[0].objects[i].d3=1;
12185 else
12186 custom_subscreen[0].objects[i].d3=0;
12187
12188 break;
12189 }
12190
12191 default:
12192 memcpy(&custom_subscreen[0].objects[i],&tempsub[i],sizeof(subscreen_object));
12193 break;
12194 }
12195 }
12196
12197 custom_subscreen[0].ss_type=sstACTIVE;
12198 // memset(&custom_subscreen[0].objects[i],0,sizeof(subscreen_object));
12199 tempsub = z3_active_ab;
12200
12201 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12202 {
12203 switch(tempsub[i].type)
12204 {
12205 case ssoTEXT:
12206 case ssoTEXTBOX:
12207 case ssoCURRENTITEMTEXT:
12208 case ssoCURRENTITEMCLASSTEXT:
12209 if(custom_subscreen[1].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[1].objects[i].dp1;
12210
12211 memcpy(&custom_subscreen[1].objects[i],&tempsub[i],sizeof(subscreen_object));
12212 custom_subscreen[1].objects[i].dp1 = NULL;
12213 custom_subscreen[1].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12214 strcpy((char*)custom_subscreen[1].objects[i].dp1,(char*)tempsub[i].dp1);
12215 break;
12216
12217 case ssoLIFEMETER:
12218 {
12219 memcpy(&custom_subscreen[1].objects[i],&tempsub[i],sizeof(subscreen_object));
12220
12221 if(get_bit(deprecated_rules, 12) != 0)
12222 custom_subscreen[1].objects[i].d3=1;
12223 else
12224 custom_subscreen[1].objects[i].d3=0;
12225
12226 break;
12227 }
12228
12229 default:
12230 memcpy(&custom_subscreen[1].objects[i],&tempsub[i],sizeof(subscreen_object));
12231 break;
12232 }
12233 }
12234
12235 custom_subscreen[1].ss_type=sstACTIVE;
12236 // memset(&custom_subscreen[1].objects[i],0,sizeof(subscreen_object));
12237 tempsub = z3_passive_a;
12238
12239 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12240 {
12241 switch(tempsub[i].type)
12242 {
12243 case ssoTEXT:
12244 case ssoTEXTBOX:
12245 case ssoCURRENTITEMTEXT:
12246 case ssoCURRENTITEMCLASSTEXT:
12247 if(custom_subscreen[2].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[2].objects[i].dp1;
12248
12249 memcpy(&custom_subscreen[2].objects[i],&tempsub[i],sizeof(subscreen_object));
12250 custom_subscreen[2].objects[i].dp1 = NULL;
12251 custom_subscreen[2].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12252 strcpy((char*)custom_subscreen[2].objects[i].dp1,(char*)tempsub[i].dp1);
12253 break;
12254
12255 case ssoLIFEMETER:
12256 {
12257 memcpy(&custom_subscreen[2].objects[i],&tempsub[i],sizeof(subscreen_object));
12258
12259 if(get_bit(deprecated_rules, 12) != 0)
12260 custom_subscreen[2].objects[i].d3=1;
12261 else
12262 custom_subscreen[2].objects[i].d3=0;
12263
12264 break;
12265 }
12266
12267 default:
12268 memcpy(&custom_subscreen[2].objects[i],&tempsub[i],sizeof(subscreen_object));
12269 break;
12270 }
12271 }
12272
12273 custom_subscreen[2].ss_type=sstPASSIVE;
12274 // memset(&custom_subscreen[2].objects[i],0,sizeof(subscreen_object));
12275 tempsub = z3_passive_ab;
12276
12277 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12278 {
12279 switch(tempsub[i].type)
12280 {
12281 case ssoTEXT:
12282 case ssoTEXTBOX:
12283 case ssoCURRENTITEMTEXT:
12284 case ssoCURRENTITEMCLASSTEXT:
12285 if(custom_subscreen[3].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[3].objects[i].dp1;
12286
12287 memcpy(&custom_subscreen[3].objects[i],&tempsub[i],sizeof(subscreen_object));
12288 custom_subscreen[3].objects[i].dp1 = NULL;
12289 custom_subscreen[3].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12290 strcpy((char*)custom_subscreen[3].objects[i].dp1,(char*)tempsub[i].dp1);
12291 break;
12292
12293 case ssoLIFEMETER:
12294 {
12295 memcpy(&custom_subscreen[3].objects[i],&tempsub[i],sizeof(subscreen_object));
12296
12297 if(get_bit(deprecated_rules, 12) != 0)
12298 custom_subscreen[3].objects[i].d3=1;
12299 else
12300 custom_subscreen[3].objects[i].d3=0;
12301
12302 break;
12303 }
12304
12305 default:
12306 memcpy(&custom_subscreen[3].objects[i],&tempsub[i],sizeof(subscreen_object));
12307 break;
12308 }
12309 }
12310
12311 custom_subscreen[3].ss_type=sstPASSIVE;
12312 // memset(&custom_subscreen[3].objects[i],0,sizeof(subscreen_object));
12313 break;
12314 }
12315 }
12316
12317
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 36 times.
45 for(int32_t i=0; i<4; ++i)
12318 {
12319 36 purge_blank_subscreen_objects(&custom_subscreen[i]);
12320 36 }
12321
12322 9 return 0;
12323 }
12324
12325 extern script_data *ffscripts[NUMSCRIPTFFC];
12326 extern script_data *itemscripts[NUMSCRIPTITEM];
12327 extern script_data *guyscripts[NUMSCRIPTGUYS];
12328 extern script_data *wpnscripts[NUMSCRIPTWEAPONS];
12329 extern script_data *lwpnscripts[NUMSCRIPTWEAPONS];
12330 extern script_data *ewpnscripts[NUMSCRIPTWEAPONS];
12331 extern script_data *globalscripts[NUMSCRIPTGLOBAL];
12332 extern script_data *genericscripts[NUMSCRIPTSGENERIC];
12333 extern script_data *playerscripts[NUMSCRIPTPLAYER];
12334 extern script_data *screenscripts[NUMSCRIPTSCREEN];
12335 extern script_data *dmapscripts[NUMSCRIPTSDMAP];
12336 extern script_data *itemspritescripts[NUMSCRIPTSITEMSPRITE];
12337 extern script_data *comboscripts[NUMSCRIPTSCOMBODATA];
12338 //script_data *wpnscripts[NUMSCRIPTWEAPONS]; //used only for old data
12339
12340
12341
12342 58 int32_t readffscript(PACKFILE *f, zquestheader *Header, bool keepdata)
12343 {
12344 int32_t dummy;
12345 58 word s_version=0, s_cversion=0, zmeta_version=0;
12346 58 byte numscripts=0;
12347 58 numscripts=numscripts; //to avoid unused variables warnings
12348 int32_t ret;
12349
12350 //section version info
12351
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 if(!p_igetw(&s_version,f,true))
12352 {
12353 return qe_invalid;
12354 }
12355
12356 58 FFCore.quest_format[vFFScript] = s_version;
12357
12358
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(!p_igetw(&s_cversion,f,true))
12359 {
12360 return qe_invalid;
12361 }
12362
12363
2/2
✓ Branch 0 taken 55 times.
✓ Branch 1 taken 3 times.
58 if(s_version >= 18)
12364 {
12365
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_igetw(&zmeta_version,f,true))
12366 {
12367 return qe_invalid;
12368 }
12369 3 }
12370
12371 //al_trace("Scripts version %d\n", s_version);
12372 //section size
12373
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(!p_igetl(&dummy,f,true))
12374 {
12375 return qe_invalid;
12376 }
12377
12378 //ZScriptVersion::setVersion(s_version); ~this ideally, but there's no ZC/ZQuest defines...
12379 58 setZScriptVersion(s_version); //Lumped in zelda.cpp and in zquest.cpp as zquest can't link ZScriptVersion
12380 58 temp_ffscript_version = s_version;
12381 //miscQdata *the_misc;
12382
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 55 times.
58 if ( FFCore.quest_format[vLastCompile] < 13 ) FFCore.quest_format[vLastCompile] = s_version;
12383 58 al_trace("Loaded scripts last compiled in ZScript version: %d\n", (FFCore.quest_format[vLastCompile]));
12384
12385 //finally... section data
12386
2/2
✓ Branch 0 taken 29696 times.
✓ Branch 1 taken 58 times.
29754 for(int32_t i = 0; i < ((s_version < 2) ? NUMSCRIPTFFCOLD : NUMSCRIPTFFC); i++)
12387 {
12388 29696 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &ffscripts[i], zmeta_version);
12389
12390
1/2
✓ Branch 0 taken 29696 times.
✗ Branch 1 not taken.
29696 if(ret != 0) return qe_invalid;
12391 29696 }
12392
12393 /* HIGHLY UNORTHODOX UPDATING THING, by Deedee
12394 * This fixes changes to sprite jump values introduced in early 2.55 alphas.
12395 * Zoria didn't bump up the versions as liberally as he should have, but thankfully
12396 * there was a version bump a week before a change that broke stuff.
12397 */
12398
6/8
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 55 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3 times.
✓ Branch 7 taken 55 times.
58 if(((Header->zelda_version < 0x253)||((Header->zelda_version == 0x253)&&(Header->build<33))||((Header->zelda_version > 0x253) && s_version < 12)) && keepdata)
12399 {
12400 55 set_bit(quest_rules,qr_SPRITE_JUMP_IS_TRUNCATED,1);
12401 55 }
12402
3/4
✓ Branch 0 taken 55 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 55 times.
58 if(s_version < 19 && keepdata)
12403 {
12404 55 set_bit(quest_rules,qr_FLUCTUATING_ENEMY_JUMP,1);
12405 55 }
12406
12407
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 if(s_version > 1)
12408 {
12409
2/2
✓ Branch 0 taken 14848 times.
✓ Branch 1 taken 58 times.
14906 for(int32_t i = 0; i < NUMSCRIPTITEM; i++)
12410 {
12411 14848 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &itemscripts[i], zmeta_version);
12412
12413
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(ret != 0) return qe_invalid;
12414 14848 }
12415
12416
2/2
✓ Branch 0 taken 14848 times.
✓ Branch 1 taken 58 times.
14906 for(int32_t i = 0; i < NUMSCRIPTGUYS; i++)
12417 {
12418 14848 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &guyscripts[i], zmeta_version);
12419
12420
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(ret != 0) return qe_invalid;
12421 14848 }
12422
12423
2/2
✓ Branch 0 taken 14848 times.
✓ Branch 1 taken 58 times.
14906 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12424 {
12425 14848 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &wpnscripts[i], zmeta_version);
12426
12427
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(ret != 0) return qe_invalid;
12428 14848 }
12429
12430
12431
2/2
✓ Branch 0 taken 14848 times.
✓ Branch 1 taken 58 times.
14906 for(int32_t i = 0; i < NUMSCRIPTSCREEN; i++)
12432 {
12433 14848 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &screenscripts[i], zmeta_version);
12434
12435
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(ret != 0) return qe_invalid;
12436 14848 }
12437
12438
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 55 times.
58 if(s_version > 16)
12439 {
12440
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 3 times.
27 for(int32_t i = 0; i < NUMSCRIPTGLOBAL; ++i)
12441 {
12442 24 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &globalscripts[i], zmeta_version);
12443
12444
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(ret != 0) return qe_invalid;
12445 24 }
12446 3 }
12447
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
55 else if(s_version > 13)
12448 {
12449 for(int32_t i = 0; i < NUMSCRIPTGLOBAL255OLD; ++i)
12450 {
12451 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &globalscripts[i], zmeta_version);
12452
12453 if(ret != 0) return qe_invalid;
12454 }
12455
12456 if(globalscripts[GLOBAL_SCRIPT_ONSAVE] != NULL)
12457 delete globalscripts[GLOBAL_SCRIPT_ONSAVE];
12458
12459 globalscripts[GLOBAL_SCRIPT_ONSAVE] = new script_data();
12460 }
12461
1/2
✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
55 else if(s_version > 4)
12462 {
12463
2/2
✓ Branch 0 taken 220 times.
✓ Branch 1 taken 55 times.
275 for(int32_t i = 0; i < NUMSCRIPTGLOBAL253; ++i)
12464 {
12465 220 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &globalscripts[i], zmeta_version);
12466
12467
1/2
✓ Branch 0 taken 220 times.
✗ Branch 1 not taken.
220 if(ret != 0) return qe_invalid;
12468 220 }
12469
12470
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
55 if(globalscripts[GLOBAL_SCRIPT_ONLAUNCH] != NULL)
12471
1/2
✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
55 delete globalscripts[GLOBAL_SCRIPT_ONLAUNCH];
12472
12473
1/2
✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
55 globalscripts[GLOBAL_SCRIPT_ONLAUNCH] = new script_data();
12474
12475
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
55 if(globalscripts[GLOBAL_SCRIPT_ONCONTGAME] != NULL)
12476
1/2
✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
55 delete globalscripts[GLOBAL_SCRIPT_ONCONTGAME];
12477
12478
1/2
✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
55 globalscripts[GLOBAL_SCRIPT_ONCONTGAME] = new script_data();
12479
12480
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
55 if(globalscripts[GLOBAL_SCRIPT_F6] != NULL)
12481
1/2
✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
55 delete globalscripts[GLOBAL_SCRIPT_F6];
12482
12483
1/2
✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
55 globalscripts[GLOBAL_SCRIPT_F6] = new script_data();
12484
12485
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
55 if(globalscripts[GLOBAL_SCRIPT_ONSAVE] != NULL)
12486
1/2
✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
55 delete globalscripts[GLOBAL_SCRIPT_ONSAVE];
12487
12488
1/2
✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
55 globalscripts[GLOBAL_SCRIPT_ONSAVE] = new script_data();
12489 55 }
12490 else
12491 {
12492 for(int32_t i = 0; i < NUMSCRIPTGLOBALOLD; i++)
12493 {
12494 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &globalscripts[i], zmeta_version);
12495
12496 if(ret != 0) return qe_invalid;
12497 }
12498
12499 if(globalscripts[GLOBAL_SCRIPT_ONSAVELOAD] != NULL)
12500 delete globalscripts[GLOBAL_SCRIPT_ONSAVELOAD];
12501
12502 globalscripts[GLOBAL_SCRIPT_ONSAVELOAD] = new script_data();
12503
12504 if(globalscripts[GLOBAL_SCRIPT_ONLAUNCH] != NULL)
12505 delete globalscripts[GLOBAL_SCRIPT_ONLAUNCH];
12506
12507 globalscripts[GLOBAL_SCRIPT_ONLAUNCH] = new script_data();
12508
12509 if(globalscripts[GLOBAL_SCRIPT_ONCONTGAME] != NULL)
12510 delete globalscripts[GLOBAL_SCRIPT_ONCONTGAME];
12511
12512 globalscripts[GLOBAL_SCRIPT_ONCONTGAME] = new script_data();
12513
12514 if(globalscripts[GLOBAL_SCRIPT_F6] != NULL)
12515 delete globalscripts[GLOBAL_SCRIPT_F6];
12516
12517 globalscripts[GLOBAL_SCRIPT_F6] = new script_data();
12518
12519 if(globalscripts[GLOBAL_SCRIPT_ONSAVE] != NULL)
12520 delete globalscripts[GLOBAL_SCRIPT_ONSAVE];
12521
12522 globalscripts[GLOBAL_SCRIPT_ONSAVE] = new script_data();
12523 }
12524
12525
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 55 times.
58 if(s_version > 10) //expanded the number of Player scripts to 5.
12526 {
12527
2/2
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 3 times.
18 for(int32_t i = 0; i < NUMSCRIPTPLAYER; i++)
12528 {
12529 15 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &playerscripts[i], zmeta_version);
12530
12531
1/2
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
15 if(ret != 0) return qe_invalid;
12532 15 }
12533 3 }
12534 else
12535 {
12536
2/2
✓ Branch 0 taken 165 times.
✓ Branch 1 taken 55 times.
220 for(int32_t i = 0; i < NUMSCRIPTHEROOLD; i++)
12537 {
12538 165 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &playerscripts[i], zmeta_version);
12539
12540
1/2
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
165 if(ret != 0) return qe_invalid;
12541 165 }
12542
1/2
✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
55 if(playerscripts[3] != NULL)
12543
1/2
✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
55 delete playerscripts[3];
12544
12545
1/2
✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
55 playerscripts[3] = new script_data();
12546
12547
1/2
✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
55 if(playerscripts[4] != NULL)
12548
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
55 delete playerscripts[4];
12549
12550
1/2
✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
55 playerscripts[4] = new script_data();
12551 }
12552
3/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 55 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
58 if(s_version > 8 && s_version < 10)
12553 {
12554
12555 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12556 {
12557 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &ewpnscripts[i], zmeta_version);
12558
12559 if(ret != 0) return qe_invalid;
12560 }
12561 for(int32_t i = 0; i < NUMSCRIPTSDMAP; i++)
12562 {
12563 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &dmapscripts[i], zmeta_version);
12564
12565 if(ret != 0) return qe_invalid;
12566 }
12567
12568 }
12569
2/2
✓ Branch 0 taken 55 times.
✓ Branch 1 taken 3 times.
58 if(s_version >= 10)
12570 {
12571
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 3 times.
771 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12572 {
12573 768 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &lwpnscripts[i], zmeta_version);
12574
12575
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(ret != 0) return qe_invalid;
12576 768 }
12577
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 3 times.
771 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12578 {
12579 768 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &ewpnscripts[i], zmeta_version);
12580
12581
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(ret != 0) return qe_invalid;
12582 768 }
12583
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 3 times.
771 for(int32_t i = 0; i < NUMSCRIPTSDMAP; i++)
12584 {
12585 768 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &dmapscripts[i], zmeta_version);
12586
12587
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(ret != 0) return qe_invalid;
12588 768 }
12589
12590 3 }
12591
2/2
✓ Branch 0 taken 55 times.
✓ Branch 1 taken 3 times.
58 if(s_version >=12)
12592 {
12593
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 3 times.
771 for(int32_t i = 0; i < NUMSCRIPTSITEMSPRITE; i++)
12594 {
12595 768 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &itemspritescripts[i], zmeta_version);
12596
12597
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(ret != 0) return qe_invalid;
12598 768 }
12599 3 }
12600
2/2
✓ Branch 0 taken 55 times.
✓ Branch 1 taken 3 times.
58 if(s_version >=15)
12601 {
12602
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 3 times.
1539 for(int32_t i = 0; i < NUMSCRIPTSCOMBODATA; i++)
12603 {
12604 1536 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &comboscripts[i], zmeta_version);
12605
12606
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(ret != 0) return qe_invalid;
12607 1536 }
12608 3 }
12609
2/2
✓ Branch 0 taken 55 times.
✓ Branch 1 taken 3 times.
58 if(s_version >19)
12610 {
12611 3 word numgenscripts = NUMSCRIPTSGENERIC;
12612
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_igetw(&numgenscripts,f,true))
12613 {
12614 return qe_invalid;
12615 }
12616
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 3 times.
1539 for(int32_t i = 0; i < numgenscripts; i++)
12617 {
12618 1536 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &genericscripts[i], zmeta_version);
12619
12620
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(ret != 0) return qe_invalid;
12621 1536 }
12622 3 }
12623
12624 /*
12625 else //Is this trip really necessary?
12626 {
12627 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12628 {
12629
12630 ewpnscripts[i] = NULL;
12631 }
12632 for(int32_t i = 0; i < NUMSCRIPTSDMAP; i++)
12633 {
12634 dmapscripts[i] = NULL;
12635 }
12636 }
12637 */
12638
12639 58 }
12640
12641
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 if(s_version > 2)
12642 {
12643 int32_t bufsize;
12644 58 p_igetl(&bufsize, f, true);
12645 58 char * buf = new char[bufsize+1];
12646 58 pfread(buf, bufsize, f, true);
12647 58 buf[bufsize]=0;
12648
12649
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 if(keepdata)
12650 58 zScript = string(buf);
12651
12652
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 delete[] buf;
12653 word numffcbindings;
12654 58 p_igetw(&numffcbindings, f, true);
12655
12656
2/2
✓ Branch 0 taken 431 times.
✓ Branch 1 taken 58 times.
489 for(int32_t i=0; i<numffcbindings; i++)
12657 {
12658 word id;
12659 431 p_igetw(&id, f, true);
12660 431 p_igetl(&bufsize, f, true);
12661 431 buf = new char[bufsize+1];
12662 431 pfread(buf, bufsize, f, true);
12663 431 buf[bufsize]=0;
12664
12665 //fix for buggy older saved quests -DD
12666
2/4
✓ Branch 0 taken 431 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 431 times.
431 if(keepdata && id < NUMSCRIPTFFC-1)
12667 431 ffcmap[id].scriptname = buf;
12668
12669
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 431 times.
431 delete[] buf;
12670 431 }
12671
12672 word numglobalbindings;
12673 58 p_igetw(&numglobalbindings, f, true);
12674
12675
2/2
✓ Branch 0 taken 294 times.
✓ Branch 1 taken 58 times.
352 for(int32_t i=0; i<numglobalbindings; i++)
12676 {
12677 word id;
12678 294 p_igetw(&id, f, true);
12679 294 p_igetl(&bufsize, f, true);
12680 294 buf = new char[bufsize+1];
12681 294 pfread(buf, bufsize, f, true);
12682 294 buf[bufsize]=0;
12683
12684 // id in principle should be valid, since slot assignment cannot assign a global script to a bogus slot.
12685 // However, because of a corruption bug, some 2.50.x quests contain bogus entries in the global bindings table.
12686 // Ignore these. -DD
12687
4/6
✓ Branch 0 taken 294 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 294 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 133 times.
✓ Branch 5 taken 161 times.
294 if(keepdata && id >= 0 && id < NUMSCRIPTGLOBAL)
12688 {
12689 //Disable old '~Continue's, they'd wreak havoc. Bit messy, apologies ~Joe
12690
1/2
✓ Branch 0 taken 161 times.
✗ Branch 1 not taken.
161 if(strcmp(buf,"~Continue") == 0)
12691 {
12692 globalmap[id].scriptname = "";
12693
12694 if(globalscripts[GLOBAL_SCRIPT_ONSAVELOAD] != NULL)
12695 globalscripts[GLOBAL_SCRIPT_ONSAVELOAD]->disable();
12696 }
12697 else
12698 {
12699 161 globalmap[id].scriptname = buf;
12700 }
12701 161 }
12702
12703
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 294 times.
294 delete[] buf;
12704 294 }
12705
12706
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 if(s_version > 3)
12707 {
12708 word numitembindings;
12709 58 p_igetw(&numitembindings, f, true);
12710
12711
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 58 times.
68 for(int32_t i=0; i<numitembindings; i++)
12712 {
12713 word id;
12714 10 p_igetw(&id, f, true);
12715 10 p_igetl(&bufsize, f, true);
12716 10 buf = new char[bufsize+1];
12717 10 pfread(buf, bufsize, f, true);
12718 10 buf[bufsize]=0;
12719
12720 //fix this too
12721
2/4
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 10 times.
10 if(keepdata && id <NUMSCRIPTITEM-1)
12722 10 itemmap[id].scriptname = buf;
12723
12724
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 delete[] buf;
12725 10 }
12726 58 }
12727 //(v9+)
12728
2/2
✓ Branch 0 taken 55 times.
✓ Branch 1 taken 3 times.
58 if(s_version > 8)
12729 {
12730 //npc scripts
12731 word numnpcbindings;
12732 3 p_igetw(&numnpcbindings, f, true);
12733
12734
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 for(int32_t i=0; i<numnpcbindings; i++)
12735 {
12736 word id;
12737 p_igetw(&id, f, true);
12738 p_igetl(&bufsize, f, true);
12739 buf = new char[bufsize+1];
12740 pfread(buf, bufsize, f, true);
12741 buf[bufsize]=0;
12742
12743 //fix this too
12744 if(keepdata && id <NUMSCRIPTGUYS-1)
12745 npcmap[id].scriptname = buf;
12746
12747 delete[] buf;
12748 }
12749 //lweapon
12750 word numlwpnbindings;
12751 3 p_igetw(&numlwpnbindings, f, true);
12752
12753
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 for(int32_t i=0; i<numlwpnbindings; i++)
12754 {
12755 word id;
12756 p_igetw(&id, f, true);
12757 p_igetl(&bufsize, f, true);
12758 buf = new char[bufsize+1];
12759 pfread(buf, bufsize, f, true);
12760 buf[bufsize]=0;
12761
12762 //fix this too
12763 if(keepdata && id <NUMSCRIPTWEAPONS-1)
12764 lwpnmap[id].scriptname = buf;
12765
12766 delete[] buf;
12767 }
12768 //eweapon
12769 word numewpnbindings;
12770 3 p_igetw(&numewpnbindings, f, true);
12771
12772
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 for(int32_t i=0; i<numewpnbindings; i++)
12773 {
12774 word id;
12775 p_igetw(&id, f, true);
12776 p_igetl(&bufsize, f, true);
12777 buf = new char[bufsize+1];
12778 pfread(buf, bufsize, f, true);
12779 buf[bufsize]=0;
12780
12781 //fix this too
12782 if(keepdata && id <NUMSCRIPTWEAPONS-1)
12783 ewpnmap[id].scriptname = buf;
12784
12785 delete[] buf;
12786 }
12787 //hero
12788 word numherobindings;
12789 3 p_igetw(&numherobindings, f, true);
12790
12791
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 for(int32_t i=0; i<numherobindings; i++)
12792 {
12793 word id;
12794 p_igetw(&id, f, true);
12795 p_igetl(&bufsize, f, true);
12796 buf = new char[bufsize+1];
12797 pfread(buf, bufsize, f, true);
12798 buf[bufsize]=0;
12799
12800 //fix this too
12801 if(keepdata && id <NUMSCRIPTPLAYER-1)
12802 playermap[id].scriptname = buf;
12803
12804 delete[] buf;
12805 }
12806 //dmaps
12807 word numdmapbindings;
12808 3 p_igetw(&numdmapbindings, f, true);
12809
12810
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 for(int32_t i=0; i<numdmapbindings; i++)
12811 {
12812 word id;
12813 p_igetw(&id, f, true);
12814 p_igetl(&bufsize, f, true);
12815 buf = new char[bufsize+1];
12816 pfread(buf, bufsize, f, true);
12817 buf[bufsize]=0;
12818
12819 //fix this too
12820 if(keepdata && id <NUMSCRIPTSDMAP-1)
12821 dmapmap[id].scriptname = buf;
12822
12823 delete[] buf;
12824 }
12825 //screen
12826 word numscreenbindings;
12827 3 p_igetw(&numscreenbindings, f, true);
12828
12829
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 for(int32_t i=0; i<numscreenbindings; i++)
12830 {
12831 word id;
12832 p_igetw(&id, f, true);
12833 p_igetl(&bufsize, f, true);
12834 buf = new char[bufsize+1];
12835 pfread(buf, bufsize, f, true);
12836 buf[bufsize]=0;
12837
12838 //fix this too
12839 if(keepdata && id <NUMSCRIPTSDMAP-1)
12840 screenmap[id].scriptname = buf;
12841
12842 delete[] buf;
12843 }
12844 3 }
12845
2/2
✓ Branch 0 taken 55 times.
✓ Branch 1 taken 3 times.
58 if(s_version > 11)
12846 {
12847 word numspritebindings;
12848 3 p_igetw(&numspritebindings, f, true);
12849
12850
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 for(int32_t i=0; i<numspritebindings; i++)
12851 {
12852 word id;
12853 p_igetw(&id, f, true);
12854 p_igetl(&bufsize, f, true);
12855 buf = new char[bufsize+1];
12856 pfread(buf, bufsize, f, true);
12857 buf[bufsize]=0;
12858
12859 //fix this too
12860 if(keepdata && id <NUMSCRIPTSDMAP-1)
12861 itemspritemap[id].scriptname = buf;
12862
12863 delete[] buf;
12864 }
12865 3 }
12866
2/2
✓ Branch 0 taken 55 times.
✓ Branch 1 taken 3 times.
58 if(s_version >= 15)
12867 {
12868 word numcombobindings;
12869 3 p_igetw(&numcombobindings, f, true);
12870
12871
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 3 times.
4 for(int32_t i=0; i<numcombobindings; i++)
12872 {
12873 word id;
12874 1 p_igetw(&id, f, true);
12875 1 p_igetl(&bufsize, f, true);
12876 1 buf = new char[bufsize+1];
12877 1 pfread(buf, bufsize, f, true);
12878 1 buf[bufsize]=0;
12879
12880 //fix this too
12881
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 if(keepdata && id <NUMSCRIPTSCOMBODATA-1)
12882 1 comboscriptmap[id].scriptname = buf;
12883
12884
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 delete[] buf;
12885 1 }
12886 3 }
12887
2/2
✓ Branch 0 taken 55 times.
✓ Branch 1 taken 3 times.
58 if(s_version > 19)
12888 {
12889 word numgenericbindings;
12890 3 p_igetw(&numgenericbindings, f, true);
12891
12892
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 3 times.
4 for(int32_t i=0; i<numgenericbindings; i++)
12893 {
12894 word id;
12895 1 p_igetw(&id, f, true);
12896 1 p_igetl(&bufsize, f, true);
12897 1 buf = new char[bufsize+1];
12898 1 pfread(buf, bufsize, f, true);
12899 1 buf[bufsize]=0;
12900
12901 //fix this too
12902
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 if(keepdata && id <NUMSCRIPTSGENERIC-1)
12903 1 genericmap[id].scriptname = buf;
12904
12905
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 delete[] buf;
12906 1 }
12907 3 }
12908 58 }
12909
12910 58 return 0;
12911 58 }
12912
12913 58 void reset_scripts()
12914 {
12915 //OK, who spaced this? ;)
12916
2/2
✓ Branch 0 taken 29696 times.
✓ Branch 1 taken 58 times.
29754 for(int32_t i=0; i<NUMSCRIPTFFC; i++)
12917 {
12918
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 29696 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 29696 times.
29696 if(ffscripts[i]!=NULL) delete ffscripts[i];
12919 29696 }
12920
12921
2/2
✓ Branch 0 taken 14848 times.
✓ Branch 1 taken 58 times.
14906 for(int32_t i=0; i<NUMSCRIPTITEM; i++)
12922 {
12923
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 14848 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 14848 times.
14848 if(itemscripts[i]!=NULL) delete itemscripts[i];
12924 14848 }
12925
12926
2/2
✓ Branch 0 taken 14848 times.
✓ Branch 1 taken 58 times.
14906 for(int32_t i=0; i<NUMSCRIPTGUYS; i++)
12927 {
12928
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 14848 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 14848 times.
14848 if(guyscripts[i]!=NULL) delete guyscripts[i];
12929 14848 }
12930
12931
2/2
✓ Branch 0 taken 14848 times.
✓ Branch 1 taken 58 times.
14906 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
12932 {
12933
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 14848 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 14848 times.
14848 if(wpnscripts[i]!=NULL) delete wpnscripts[i];
12934 14848 }
12935
12936
12937
12938
2/2
✓ Branch 0 taken 14848 times.
✓ Branch 1 taken 58 times.
14906 for(int32_t i=0; i<NUMSCRIPTSCREEN; i++)
12939 {
12940
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 14848 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 14848 times.
14848 if(screenscripts[i]!=NULL) delete screenscripts[i];
12941 14848 }
12942
12943
2/2
✓ Branch 0 taken 464 times.
✓ Branch 1 taken 58 times.
522 for(int32_t i=0; i<NUMSCRIPTGLOBAL; i++)
12944 {
12945
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 464 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 464 times.
464 if(globalscripts[i]!=NULL) delete globalscripts[i];
12946 464 }
12947
12948
2/2
✓ Branch 0 taken 290 times.
✓ Branch 1 taken 58 times.
348 for(int32_t i=0; i<NUMSCRIPTPLAYER; i++)
12949 {
12950
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 290 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 290 times.
290 if(playerscripts[i]!=NULL) delete playerscripts[i];
12951 290 }
12952
12953
2/2
✓ Branch 0 taken 14848 times.
✓ Branch 1 taken 58 times.
14906 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
12954 {
12955
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 14848 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 14848 times.
14848 if(lwpnscripts[i]!=NULL) delete lwpnscripts[i];
12956 14848 }
12957
12958
2/2
✓ Branch 0 taken 14848 times.
✓ Branch 1 taken 58 times.
14906 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
12959 {
12960
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 14848 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 14848 times.
14848 if(ewpnscripts[i]!=NULL) delete ewpnscripts[i];
12961 14848 }
12962
12963
2/2
✓ Branch 0 taken 14848 times.
✓ Branch 1 taken 58 times.
14906 for(int32_t i=0; i<NUMSCRIPTSDMAP; i++)
12964 {
12965
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 14848 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 14848 times.
14848 if(dmapscripts[i]!=NULL) delete dmapscripts[i];
12966 14848 }
12967
12968
2/2
✓ Branch 0 taken 14848 times.
✓ Branch 1 taken 58 times.
14906 for(int32_t i=0; i<NUMSCRIPTSITEMSPRITE; i++)
12969 {
12970
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 14848 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 14848 times.
14848 if(itemspritescripts[i]!=NULL) delete itemspritescripts[i];
12971 14848 }
12972
12973
2/2
✓ Branch 0 taken 29696 times.
✓ Branch 1 taken 58 times.
29754 for(int32_t i=0; i<NUMSCRIPTSCOMBODATA; i++)
12974 {
12975
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 29696 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 29696 times.
29696 if(comboscripts[i]!=NULL) delete comboscripts[i];
12976 29696 }
12977
12978
2/2
✓ Branch 0 taken 29696 times.
✓ Branch 1 taken 58 times.
29754 for(int32_t i=0; i<NUMSCRIPTSGENERIC; i++)
12979 {
12980
3/4
✓ Branch 0 taken 4608 times.
✓ Branch 1 taken 25088 times.
✓ Branch 2 taken 25088 times.
✗ Branch 3 not taken.
29696 if(genericscripts[i]!=NULL) delete genericscripts[i];
12981
1/2
✓ Branch 0 taken 29696 times.
✗ Branch 1 not taken.
29696 genericscripts[i] = new script_data();
12982 29696 }
12983
12984
2/2
✓ Branch 0 taken 29696 times.
✓ Branch 1 taken 58 times.
29754 for(int32_t i=0; i<NUMSCRIPTFFC; i++)
12985 {
12986
1/2
✓ Branch 0 taken 29696 times.
✗ Branch 1 not taken.
29696 ffscripts[i] = new script_data();
12987 29696 }
12988
12989
2/2
✓ Branch 0 taken 14848 times.
✓ Branch 1 taken 58 times.
14906 for(int32_t i=0; i<NUMSCRIPTITEM; i++)
12990 {
12991
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 itemscripts[i] = new script_data();
12992 14848 }
12993
12994
2/2
✓ Branch 0 taken 14848 times.
✓ Branch 1 taken 58 times.
14906 for(int32_t i=0; i<NUMSCRIPTGUYS; i++)
12995 {
12996
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 guyscripts[i] = new script_data();
12997 14848 }
12998
12999
2/2
✓ Branch 0 taken 14848 times.
✓ Branch 1 taken 58 times.
14906 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
13000 {
13001
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 wpnscripts[i] = new script_data();
13002 14848 }
13003
13004
2/2
✓ Branch 0 taken 14848 times.
✓ Branch 1 taken 58 times.
14906 for(int32_t i=0; i<NUMSCRIPTSCREEN; i++)
13005 {
13006
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 screenscripts[i] = new script_data();
13007 14848 }
13008
13009
2/2
✓ Branch 0 taken 464 times.
✓ Branch 1 taken 58 times.
522 for(int32_t i=0; i<NUMSCRIPTGLOBAL; i++)
13010 {
13011
1/2
✓ Branch 0 taken 464 times.
✗ Branch 1 not taken.
464 globalscripts[i] = new script_data();
13012 464 }
13013
13014
2/2
✓ Branch 0 taken 290 times.
✓ Branch 1 taken 58 times.
348 for(int32_t i=0; i<NUMSCRIPTPLAYER; i++)
13015 {
13016
1/2
✓ Branch 0 taken 290 times.
✗ Branch 1 not taken.
290 playerscripts[i] = new script_data();
13017 290 }
13018
13019
2/2
✓ Branch 0 taken 14848 times.
✓ Branch 1 taken 58 times.
14906 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
13020 {
13021
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 lwpnscripts[i] = new script_data();
13022 14848 }
13023
2/2
✓ Branch 0 taken 14848 times.
✓ Branch 1 taken 58 times.
14906 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
13024 {
13025
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 ewpnscripts[i] = new script_data();
13026 14848 }
13027
13028
2/2
✓ Branch 0 taken 14848 times.
✓ Branch 1 taken 58 times.
14906 for(int32_t i=0; i<NUMSCRIPTSDMAP; i++)
13029 {
13030
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 dmapscripts[i] = new script_data();
13031 14848 }
13032
2/2
✓ Branch 0 taken 14848 times.
✓ Branch 1 taken 58 times.
14906 for(int32_t i=0; i<NUMSCRIPTSITEMSPRITE; i++)
13033 {
13034
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 itemspritescripts[i] = new script_data();
13035 14848 }
13036
2/2
✓ Branch 0 taken 29696 times.
✓ Branch 1 taken 58 times.
29754 for(int32_t i=0; i<NUMSCRIPTSCOMBODATA; i++)
13037 {
13038
1/2
✓ Branch 0 taken 29696 times.
✗ Branch 1 not taken.
29696 comboscripts[i] = new script_data();
13039 29696 }
13040 58 }
13041
13042 extern script_command command_list[];
13043 95656 int32_t read_one_ffscript(PACKFILE *f, zquestheader *, bool keepdata, int32_t , word s_version, word , script_data **script, word zmeta_version)
13044 {
13045 //Please also update loadquest() when modifying this method -DD
13046 95656 char b33[34] = {0};
13047 95656 b33[33] = 0;
13048 95656 ffscript temp_script;
13049 95656 int32_t num_commands=1000;
13050
13051
1/2
✓ Branch 0 taken 95656 times.
✗ Branch 1 not taken.
95656 if(s_version>=2)
13052 {
13053
2/4
✓ Branch 0 taken 95656 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 95656 times.
✗ Branch 3 not taken.
95656 if(!p_igetl(&num_commands,f,true))
13054 {
13055 return qe_invalid;
13056 }
13057 95656 }
13058
13059
1/2
✓ Branch 0 taken 95656 times.
✗ Branch 1 not taken.
95656 if(keepdata)
13060 {
13061
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 95656 times.
95656 if((*script) != NULL) //Surely we want to do this regardless of keepdata? //No, we don't -V
13062
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 95656 times.
95656 delete (*script);
13063
2/4
✓ Branch 0 taken 95656 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 95656 times.
✗ Branch 3 not taken.
95656 (*script) = new script_data(num_commands);
13064 95656 }
13065
2/2
✓ Branch 0 taken 10791 times.
✓ Branch 1 taken 84865 times.
95656 if(s_version >= 16)
13066 {
13067
1/2
✓ Branch 0 taken 10791 times.
✗ Branch 1 not taken.
10791 zasm_meta temp_meta;
13068
13069
2/4
✓ Branch 0 taken 10791 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10791 times.
✗ Branch 3 not taken.
10791 if(!p_igetw(&(temp_meta.zasm_v),f,true))
13070 {
13071 return qe_invalid;
13072 }
13073
13074
2/4
✓ Branch 0 taken 10791 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10791 times.
✗ Branch 3 not taken.
10791 if(!p_igetw(&(temp_meta.meta_v),f,true))
13075 {
13076 return qe_invalid;
13077 }
13078
13079
2/4
✓ Branch 0 taken 10791 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10791 times.
✗ Branch 3 not taken.
10791 if(!p_igetw(&(temp_meta.ffscript_v),f,true))
13080 {
13081 return qe_invalid;
13082 }
13083
13084
2/4
✓ Branch 0 taken 10791 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10791 times.
✗ Branch 3 not taken.
10791 if(!p_getc(&(temp_meta.script_type),f,true))
13085 {
13086 return qe_invalid;
13087 }
13088
13089
2/2
✓ Branch 0 taken 86328 times.
✓ Branch 1 taken 10791 times.
97119 for(int32_t q = 0; q < 8; ++q)
13090 {
13091
2/2
✓ Branch 0 taken 28776 times.
✓ Branch 1 taken 57552 times.
86328 if(zmeta_version < 3)
13092 {
13093
2/2
✓ Branch 0 taken 28776 times.
✓ Branch 1 taken 949608 times.
978384 for(int32_t c = 0; c < 33; ++c)
13094 {
13095
2/4
✓ Branch 0 taken 949608 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 949608 times.
✗ Branch 3 not taken.
949608 if(!p_getc(&(b33[c]),f,true))
13096 {
13097 return qe_invalid;
13098 }
13099 949608 }
13100
1/2
✓ Branch 0 taken 28776 times.
✗ Branch 1 not taken.
28776 temp_meta.run_idens[q].assign(b33);
13101 28776 }
13102 else
13103 {
13104
2/4
✓ Branch 0 taken 57552 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 57552 times.
✗ Branch 3 not taken.
57552 if(!p_getcstr(&temp_meta.run_idens[q],f,true))
13105 {
13106 return qe_invalid;
13107 }
13108 }
13109 86328 }
13110
13111
2/2
✓ Branch 0 taken 10791 times.
✓ Branch 1 taken 86328 times.
97119 for(int32_t q = 0; q < 8; ++q)
13112 {
13113
2/4
✓ Branch 0 taken 86328 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 86328 times.
✗ Branch 3 not taken.
86328 if(!p_getc(&(temp_meta.run_types[q]),f,true))
13114 {
13115 return qe_invalid;
13116 }
13117 86328 }
13118
13119
2/4
✓ Branch 0 taken 10791 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10791 times.
✗ Branch 3 not taken.
10791 if(!p_getc(&(temp_meta.flags),f,true))
13120 {
13121 return qe_invalid;
13122 }
13123
13124
2/4
✓ Branch 0 taken 10791 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10791 times.
✗ Branch 3 not taken.
10791 if(!p_igetw(&(temp_meta.compiler_v1),f,true))
13125 {
13126 return qe_invalid;
13127 }
13128
13129
2/4
✓ Branch 0 taken 10791 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10791 times.
✗ Branch 3 not taken.
10791 if(!p_igetw(&(temp_meta.compiler_v2),f,true))
13130 {
13131 return qe_invalid;
13132 }
13133
13134
2/4
✓ Branch 0 taken 10791 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10791 times.
✗ Branch 3 not taken.
10791 if(!p_igetw(&(temp_meta.compiler_v3),f,true))
13135 {
13136 return qe_invalid;
13137 }
13138
13139
2/4
✓ Branch 0 taken 10791 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10791 times.
✗ Branch 3 not taken.
10791 if(!p_igetw(&(temp_meta.compiler_v4),f,true))
13140 {
13141 return qe_invalid;
13142 }
13143
13144
2/2
✓ Branch 0 taken 3597 times.
✓ Branch 1 taken 7194 times.
10791 if(zmeta_version == 2)
13145 {
13146
2/2
✓ Branch 0 taken 3597 times.
✓ Branch 1 taken 118701 times.
122298 for(int32_t c = 0; c < 33; ++c)
13147 {
13148
2/4
✓ Branch 0 taken 118701 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 118701 times.
✗ Branch 3 not taken.
118701 if(!p_getc(&b33[c],f,true))
13149 {
13150 return qe_invalid;
13151 }
13152 118701 }
13153
1/2
✓ Branch 0 taken 3597 times.
✗ Branch 1 not taken.
3597 temp_meta.script_name.assign(b33);
13154
13155
2/2
✓ Branch 0 taken 3597 times.
✓ Branch 1 taken 118701 times.
122298 for(int32_t c = 0; c < 33; ++c)
13156 {
13157
2/4
✓ Branch 0 taken 118701 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 118701 times.
✗ Branch 3 not taken.
118701 if(!p_getc(&b33[c],f,true))
13158 {
13159 return qe_invalid;
13160 }
13161 118701 }
13162
1/2
✓ Branch 0 taken 3597 times.
✗ Branch 1 not taken.
3597 temp_meta.author.assign(b33);
13163 3597 }
13164
1/2
✓ Branch 0 taken 7194 times.
✗ Branch 1 not taken.
7194 else if(zmeta_version > 2)
13165 {
13166
2/4
✓ Branch 0 taken 7194 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7194 times.
✗ Branch 3 not taken.
7194 if(!p_getcstr(&temp_meta.script_name,f,true))
13167 return qe_invalid;
13168
2/4
✓ Branch 0 taken 7194 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7194 times.
✗ Branch 3 not taken.
7194 if(!p_getcstr(&temp_meta.author,f,true))
13169 return qe_invalid;
13170 7194 auto num_meta_attrib = (zmeta_version < 5 ? 4 : 10);
13171
2/2
✓ Branch 0 taken 71940 times.
✓ Branch 1 taken 7194 times.
79134 for(auto q = 0; q < num_meta_attrib; ++q)
13172 {
13173
2/4
✓ Branch 0 taken 71940 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 71940 times.
✗ Branch 3 not taken.
71940 if(!p_getcstr(&temp_meta.attributes[q],f,true))
13174 return qe_invalid;
13175
2/4
✓ Branch 0 taken 71940 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 71940 times.
✗ Branch 3 not taken.
71940 if(!p_getwstr(&temp_meta.attributes_help[q],f,true))
13176 return qe_invalid;
13177 71940 }
13178
2/2
✓ Branch 0 taken 57552 times.
✓ Branch 1 taken 7194 times.
64746 for(auto q = 0; q < 8; ++q)
13179 {
13180
2/4
✓ Branch 0 taken 57552 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 57552 times.
✗ Branch 3 not taken.
57552 if(!p_getcstr(&temp_meta.attribytes[q],f,true))
13181 return qe_invalid;
13182
2/4
✓ Branch 0 taken 57552 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 57552 times.
✗ Branch 3 not taken.
57552 if(!p_getwstr(&temp_meta.attribytes_help[q],f,true))
13183 return qe_invalid;
13184 57552 }
13185
2/2
✓ Branch 0 taken 57552 times.
✓ Branch 1 taken 7194 times.
64746 for(auto q = 0; q < 8; ++q)
13186 {
13187
2/4
✓ Branch 0 taken 57552 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 57552 times.
✗ Branch 3 not taken.
57552 if(!p_getcstr(&temp_meta.attrishorts[q],f,true))
13188 return qe_invalid;
13189
2/4
✓ Branch 0 taken 57552 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 57552 times.
✗ Branch 3 not taken.
57552 if(!p_getwstr(&temp_meta.attrishorts_help[q],f,true))
13190 return qe_invalid;
13191 57552 }
13192
2/2
✓ Branch 0 taken 115104 times.
✓ Branch 1 taken 7194 times.
122298 for(auto q = 0; q < 16; ++q)
13193 {
13194
2/4
✓ Branch 0 taken 115104 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 115104 times.
✗ Branch 3 not taken.
115104 if(!p_getcstr(&temp_meta.usrflags[q],f,true))
13195 return qe_invalid;
13196
2/4
✓ Branch 0 taken 115104 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 115104 times.
✗ Branch 3 not taken.
115104 if(!p_getwstr(&temp_meta.usrflags_help[q],f,true))
13197 return qe_invalid;
13198 115104 }
13199 7194 }
13200
2/2
✓ Branch 0 taken 7194 times.
✓ Branch 1 taken 3597 times.
10791 if(zmeta_version > 3)
13201 {
13202
2/2
✓ Branch 0 taken 57552 times.
✓ Branch 1 taken 7194 times.
64746 for(auto q = 0; q < 8; ++q)
13203 {
13204
2/4
✓ Branch 0 taken 57552 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 57552 times.
✗ Branch 3 not taken.
57552 if(!p_getcstr(&temp_meta.initd[q],f,true))
13205 return qe_invalid;
13206
2/4
✓ Branch 0 taken 57552 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 57552 times.
✗ Branch 3 not taken.
57552 if(!p_getwstr(&temp_meta.initd_help[q],f,true))
13207 return qe_invalid;
13208 57552 }
13209
2/2
✓ Branch 0 taken 57552 times.
✓ Branch 1 taken 7194 times.
64746 for(auto q = 0; q < 8; ++q)
13210 {
13211
2/4
✓ Branch 0 taken 57552 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 57552 times.
✗ Branch 3 not taken.
57552 if(!p_getc(&temp_meta.initd_type[q],f,true))
13212 return qe_invalid;
13213 57552 }
13214 7194 }
13215 else
13216 {
13217
2/2
✓ Branch 0 taken 28776 times.
✓ Branch 1 taken 3597 times.
32373 for(auto q = 0; q < 8; ++q)
13218 {
13219
1/2
✓ Branch 0 taken 28776 times.
✗ Branch 1 not taken.
28776 temp_meta.initd[q] = temp_meta.run_idens[q];
13220 28776 }
13221 }
13222
13223
1/2
✓ Branch 0 taken 10791 times.
✗ Branch 1 not taken.
10791 if(keepdata)
13224
1/2
✓ Branch 0 taken 10791 times.
✗ Branch 1 not taken.
10791 (*script)->meta = temp_meta;
13225
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10791 times.
10791 }
13226
13227
1/2
✓ Branch 0 taken 95656 times.
✗ Branch 1 not taken.
95656 temp_script.clear();
13228
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2311181 times.
2311181 for(int32_t j=0; j<num_commands; j++)
13229 {
13230
2/4
✓ Branch 0 taken 2311181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2311181 times.
✗ Branch 3 not taken.
2311181 if(!p_igetw(&(temp_script.command),f,true))
13231 {
13232 return qe_invalid;
13233 }
13234
13235
2/2
✓ Branch 0 taken 2215525 times.
✓ Branch 1 taken 95656 times.
2311181 if(temp_script.command == 0xFFFF)
13236 {
13237
1/2
✓ Branch 0 taken 95656 times.
✗ Branch 1 not taken.
95656 if(keepdata)
13238
1/2
✓ Branch 0 taken 95656 times.
✗ Branch 1 not taken.
95656 (*script)->zasm[j].clear();
13239 95656 break;
13240 }
13241 else
13242 {
13243
2/4
✓ Branch 0 taken 2215525 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2215525 times.
✗ Branch 3 not taken.
2215525 if(!p_igetl(&(temp_script.arg1),f,keepdata))
13244 {
13245 return qe_invalid;
13246 }
13247
13248
2/4
✓ Branch 0 taken 2215525 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2215525 times.
✗ Branch 3 not taken.
2215525 if(!p_igetl(&(temp_script.arg2),f,keepdata))
13249 {
13250 return qe_invalid;
13251 }
13252
13253
2/2
✓ Branch 0 taken 1249 times.
✓ Branch 1 taken 2214276 times.
2215525 if(s_version >= 21)
13254 {
13255 1249 uint32_t sz = 0;
13256
2/4
✓ Branch 0 taken 1249 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1249 times.
✗ Branch 3 not taken.
1249 if(!p_igetl(&sz,f,keepdata))
13257 {
13258 return qe_invalid;
13259 }
13260
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1244 times.
1249 if(sz) //string found
13261 {
13262
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 temp_script.strptr = new std::string();
13263 char dummy;
13264
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 5 times.
64 for(size_t q = 0; q < sz; ++q)
13265 {
13266
2/4
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 59 times.
✗ Branch 3 not taken.
59 if(!p_getc(&dummy,f,keepdata))
13267 {
13268 return qe_invalid;
13269 }
13270
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 temp_script.strptr->push_back(dummy);
13271 59 }
13272 5 }
13273
2/4
✓ Branch 0 taken 1249 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1249 times.
✗ Branch 3 not taken.
1249 if(!p_igetl(&sz,f,keepdata))
13274 {
13275 return qe_invalid;
13276 }
13277
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1249 times.
1249 if(sz) //vector found
13278 {
13279 temp_script.vecptr = new std::vector<int32_t>();
13280 int32_t dummy;
13281 for(size_t q = 0; q < sz; ++q)
13282 {
13283 if(!p_igetl(&dummy,f,keepdata))
13284 {
13285 return qe_invalid;
13286 }
13287 temp_script.vecptr->push_back(dummy);
13288 }
13289 }
13290 1249 }
13291
13292
1/2
✓ Branch 0 taken 2215525 times.
✗ Branch 1 not taken.
2215525 if(keepdata)
13293 {
13294
1/2
✓ Branch 0 taken 2215525 times.
✗ Branch 1 not taken.
2215525 temp_script.give((*script)->zasm[j]);
13295 2215525 }
13296 }
13297
1/2
✓ Branch 0 taken 2215525 times.
✗ Branch 1 not taken.
2215525 temp_script.clear();
13298 2215525 }
13299
13300 95656 return 0;
13301 95656 }
13302
13303 extern SAMPLE customsfxdata[WAV_COUNT];
13304 extern uint8_t customsfxflag[WAV_COUNT>>3];
13305 extern int32_t sfxdat;
13306 extern DATAFILE *sfxdata;
13307 const char *old_sfx_string[Z35] =
13308 {
13309 "Arrow", "Sword beam", "Bomb blast", "Boomerang", "Subscreen cursor",
13310 "Shield is hit", "Item chime", "Roar (Dodongo, Gohma)", "Shutter", "Enemy dies",
13311 "Enemy is hit", "Low hearts warning", "Fire", "Ganon's fanfare", "Boss is hit", "Hammer",
13312 "Hookshot", "Message", "Player is hit", "Item fanfare", "Bomb placed", "Item pickup",
13313 "Refill", "Roar (Aquamentus, Gleeok, Ganon)", "Item pickup 2", "Ocean ambience",
13314 "Secret chime", "Player dies", "Stairs", "Sword", "Roar (Manhandla, Digdogger, Patra)",
13315 "Wand magic", "Whistle", "Zelda's fanfare", "Charging weapon", "Charging weapon 2",
13316 "Din's Fire", "Enemy falls from ceiling", "Farore's Wind", "Fireball", "Tall Grass slashed",
13317 "Pound pounded", "Hover Boots", "Ice magic", "Jump", "Lens of Truth off", "Lens of Truth on",
13318 "Nayru's Love shield", "Nayru's Love shield 2", "Push block", "Rock", "Spell rocket down",
13319 "Spell rocket up", "Sword spin attack", "Splash", "Summon magic", "Sword tapping",
13320 "Sword tapping (secret)", "Whistle whirlwind", "Cane of Byrna orbit"
13321 };
13322 char *sfx_string[WAV_COUNT];
13323
13324 58 int32_t readsfx(PACKFILE *f, zquestheader *Header, bool keepdata)
13325 {
13326 //these are here to bypass compiler warnings about unused arguments
13327 58 Header=Header;
13328
13329 int32_t dummy;
13330 58 word s_version=0, s_cversion=0;
13331 //int32_t ret;
13332 SAMPLE temp_sample;
13333 58 temp_sample.loop_start=0;
13334 58 temp_sample.loop_end=0;
13335 58 temp_sample.param=0;
13336
13337 //section version info
13338
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 if(!p_igetw(&s_version,f,true))
13339 {
13340 return qe_invalid;
13341 }
13342
13343 58 FFCore.quest_format[vSFX] = s_version;
13344
13345 //al_trace("SFX version %d\n", s_version);
13346
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(!p_igetw(&s_cversion,f,true))
13347 {
13348 return qe_invalid;
13349 }
13350
13351 //section size
13352
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(!p_igetl(&dummy,f,true))
13353 {
13354 return qe_invalid;
13355 }
13356
13357 /* HIGHLY UNORTHODOX UPDATING THING, by L
13358 * This fixes quests made before revision 411 (such as the 'Lost Isle Build'),
13359 * where the meaning of GOTOLESS changed. It also coincided with V_SFX
13360 * changing from 1 to 2.
13361 */
13362
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
58 if(s_version < 2 && keepdata)
13363 set_bit(quest_rules,qr_GOTOLESSNOTEQUAL,1);
13364
13365 /* End highly unorthodox updating thing */
13366
13367 58 int32_t wavcount = WAV_COUNT;
13368
13369
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(s_version < 6)
13370 wavcount = 128;
13371
13372 uint8_t tempflag[WAV_COUNT>>3];
13373
13374
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 if(s_version < 4)
13375 {
13376 memset(tempflag, 0xFF, WAV_COUNT>>3);
13377 }
13378 else
13379 {
13380
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(s_version < 6)
13381 memset(tempflag, 0, WAV_COUNT>>3);
13382
13383
2/2
✓ Branch 0 taken 1856 times.
✓ Branch 1 taken 58 times.
1914 for(int32_t i=0; i<(wavcount>>3); i++)
13384 {
13385 1856 p_getc(&tempflag[i], f, true);
13386 1856 }
13387
13388 }
13389
13390
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(s_version>4)
13391 {
13392
2/2
✓ Branch 0 taken 14790 times.
✓ Branch 1 taken 58 times.
14848 for(int32_t i=1; i<WAV_COUNT; i++)
13393 {
13394
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14790 times.
14790 if(keepdata)
13395 {
13396 14790 sprintf(sfx_string[i],"s%03d",i);
13397
13398
2/2
✓ Branch 0 taken 11310 times.
✓ Branch 1 taken 3480 times.
14790 if((i<Z35))
13399 3480 strcpy(sfx_string[i], old_sfx_string[i-1]);
13400 14790 }
13401
13402
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14790 times.
14790 if(i>=wavcount)
13403 continue;
13404
2/2
✓ Branch 0 taken 260 times.
✓ Branch 1 taken 14530 times.
14790 if(get_bit(tempflag, i-1))
13405 {
13406 char tempname[36];
13407
13408
1/2
✓ Branch 0 taken 260 times.
✗ Branch 1 not taken.
260 if(!pfread(tempname, 36, f, keepdata))
13409 {
13410 return qe_invalid;
13411 }
13412
13413
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 260 times.
260 if(keepdata)
13414 {
13415 260 strcpy(sfx_string[i], tempname);
13416 260 sfx_string[i][35] = 0; //Force NULL Termination
13417 260 }
13418 260 }
13419
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14530 times.
14530 else if(keepdata)
13420 {
13421 14530 sprintf(sfx_string[i],"s%03d",i);
13422
13423
2/2
✓ Branch 0 taken 11240 times.
✓ Branch 1 taken 3290 times.
14530 if(i<Z35)
13424 3290 strcpy(sfx_string[i], old_sfx_string[i-1]);
13425 14530 sfx_string[i][35] = 0; //Force NULL Termination
13426 14530 }
13427 14790 }
13428 58 }
13429 else
13430 {
13431 if(keepdata)
13432 {
13433 for(int32_t i=1; i<WAV_COUNT; i++)
13434 {
13435 sprintf(sfx_string[i],"s%03d",i);
13436
13437 if(i<Z35)
13438 strcpy(sfx_string[i], old_sfx_string[i-1]);
13439 }
13440 }
13441 }
13442
13443 //finally... section data
13444
2/2
✓ Branch 0 taken 14790 times.
✓ Branch 1 taken 58 times.
14848 for(int32_t i=1; i<wavcount; i++)
13445 {
13446
2/2
✓ Branch 0 taken 260 times.
✓ Branch 1 taken 14530 times.
14790 if(get_bit(tempflag, i-1))
13447 {
13448
13449
1/2
✓ Branch 0 taken 260 times.
✗ Branch 1 not taken.
260 if(!p_igetl(&dummy,f,true))
13450 {
13451 return qe_invalid;
13452 }
13453
13454 260 (temp_sample.bits) = dummy;
13455
13456
1/2
✓ Branch 0 taken 260 times.
✗ Branch 1 not taken.
260 if(!p_igetl(&dummy,f,true))
13457 {
13458 return qe_invalid;
13459 }
13460
13461 260 (temp_sample.stereo) = dummy;
13462
13463
1/2
✓ Branch 0 taken 260 times.
✗ Branch 1 not taken.
260 if(!p_igetl(&dummy,f,keepdata))
13464 {
13465 return qe_invalid;
13466 }
13467
13468 260 (temp_sample.freq) = dummy;
13469
13470
1/2
✓ Branch 0 taken 260 times.
✗ Branch 1 not taken.
260 if(!p_igetl(&dummy,f,keepdata))
13471 {
13472 return qe_invalid;
13473 }
13474
13475 260 (temp_sample.priority) = dummy;
13476
13477
1/2
✓ Branch 0 taken 260 times.
✗ Branch 1 not taken.
260 if(!p_igetl(&(temp_sample.len),f,true))
13478 {
13479 return qe_invalid;
13480 }
13481
13482
1/2
✓ Branch 0 taken 260 times.
✗ Branch 1 not taken.
260 if(!p_igetl(&(temp_sample.loop_start),f,keepdata))
13483 {
13484 return qe_invalid;
13485 }
13486
13487
1/2
✓ Branch 0 taken 260 times.
✗ Branch 1 not taken.
260 if(!p_igetl(&(temp_sample.loop_end),f,keepdata))
13488 {
13489 return qe_invalid;
13490 }
13491
13492
1/2
✓ Branch 0 taken 260 times.
✗ Branch 1 not taken.
260 if(!p_igetl(&(temp_sample.param),f,keepdata))
13493 {
13494 return qe_invalid;
13495 }
13496
13497 // al_trace("F%i: L%i\n",i,temp_sample.len);
13498 // temp_sample.data = new byte[(temp_sample.bits==8?1:2)*temp_sample.len];
13499 260 int32_t len = (temp_sample.bits==8?1:2)*(temp_sample.stereo==0?1:2)*temp_sample.len;
13500 260 temp_sample.data = calloc(len,1);
13501
13502
1/2
✓ Branch 0 taken 260 times.
✗ Branch 1 not taken.
260 if(s_version < 3)
13503 len = (temp_sample.bits==8?1:2)*temp_sample.len;
13504
13505 //old-style, non-portable loading (Bad Allegro! Bad!!) -DD
13506
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 260 times.
260 if(s_version < 2)
13507 {
13508 if(!pfread(temp_sample.data, len,f,keepdata))
13509 {
13510 return qe_invalid;
13511 }
13512 }
13513 else
13514 {
13515 //re-endianfy the data
13516 260 int32_t wordstoread = len / sizeof(word);
13517
13518
2/2
✓ Branch 0 taken 6086254 times.
✓ Branch 1 taken 260 times.
6086514 for(int32_t j=0; j<wordstoread; j++)
13519 {
13520 word temp;
13521
13522
1/2
✓ Branch 0 taken 6086254 times.
✗ Branch 1 not taken.
6086254 if(!p_igetw(&temp, f, keepdata))
13523 {
13524 return qe_invalid;
13525 }
13526
13527
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6086254 times.
6086254 if(keepdata)
13528 6086254 ((word *)temp_sample.data)[j] = temp;
13529 6086254 }
13530 }
13531 260 }
13532
2/2
✓ Branch 0 taken 3290 times.
✓ Branch 1 taken 11240 times.
14530 else if(i < Z35)
13533 {
13534 3290 SAMPLE* datsamp = (SAMPLE*)(sfxdata[i].dat);
13535 3290 memcpy(&temp_sample, datsamp, sizeof(SAMPLE));
13536 3290 set_bit(tempflag, i-1, 1);
13537 3290 int32_t len = (temp_sample.bits==8?1:2)*(temp_sample.stereo==0?1:2)*temp_sample.len;
13538 3290 temp_sample.data = calloc(len,1);
13539 3290 memcpy(temp_sample.data, datsamp->data, len);
13540 3290 }
13541 11240 else continue;
13542
13543
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3550 times.
3550 if(keepdata)
13544 {
13545
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3550 times.
3550 if(customsfxdata[i].data!=NULL)
13546 {
13547 // delete [] customsfxdata[i].data;
13548 3550 free(customsfxdata[i].data);
13549 3550 }
13550
13551 // customsfxdata[i].data = new byte[(temp_sample.bits==8?1:2)*temp_sample.len];
13552 3550 int32_t len2 = (temp_sample.bits==8?1:2)*(temp_sample.stereo==0?1:2)*temp_sample.len;
13553 3550 customsfxdata[i].data = calloc(len2,1);
13554 3550 customsfxdata[i].bits = temp_sample.bits;
13555 3550 customsfxdata[i].stereo = temp_sample.stereo;
13556 3550 customsfxdata[i].freq = temp_sample.freq;
13557 3550 customsfxdata[i].priority = temp_sample.priority;
13558 3550 customsfxdata[i].len = temp_sample.len;
13559 3550 customsfxdata[i].loop_start = temp_sample.loop_start;
13560 3550 customsfxdata[i].loop_end = temp_sample.loop_end;
13561 3550 customsfxdata[i].param = temp_sample.param;
13562 3550 int32_t cpylen = len2;
13563
13564
1/2
✓ Branch 0 taken 3550 times.
✗ Branch 1 not taken.
3550 if(s_version<3)
13565 {
13566 cpylen = (temp_sample.bits==8?1:2)*temp_sample.len;
13567 al_trace("WARNING: Quest SFX %d is in stereo, and may be corrupt.\n",i);
13568 }
13569
13570 3550 memcpy(customsfxdata[i].data,temp_sample.data,cpylen);
13571 3550 }
13572
13573 3550 free(temp_sample.data);
13574 3550 }
13575
13576
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 if(keepdata)
13577 58 memcpy(customsfxflag, tempflag, WAV_COUNT>>3);
13578
13579 58 sfxdat=0;
13580 58 return 0;
13581 58 }
13582
13583 58 void setupsfx()
13584 {
13585
2/2
✓ Branch 0 taken 14790 times.
✓ Branch 1 taken 58 times.
14848 for(int32_t i=1; i<WAV_COUNT; i++)
13586 {
13587 14790 sprintf(sfx_string[i],"s%03d",i);
13588
13589
2/2
✓ Branch 0 taken 11310 times.
✓ Branch 1 taken 3480 times.
14790 if(i<Z35)
13590 {
13591 3480 strcpy(sfx_string[i], old_sfx_string[i-1]);
13592 3480 }
13593
13594 14790 memset(customsfxflag, 0, WAV_COUNT>>3);
13595
13596 14790 int32_t j=i;
13597
13598
2/2
✓ Branch 0 taken 3538 times.
✓ Branch 1 taken 11252 times.
14790 if(i>Z35)
13599 {
13600 11252 i=Z35;
13601 11252 }
13602
13603 14790 SAMPLE *temp_sample = (SAMPLE *)sfxdata[i].dat;
13604
13605
2/2
✓ Branch 0 taken 2295 times.
✓ Branch 1 taken 12495 times.
14790 if(customsfxdata[j].data!=NULL)
13606 {
13607 // delete [] customsfxdata[j].data;
13608 12495 free(customsfxdata[j].data);
13609 12495 }
13610
13611 // customsfxdata[j].data = new byte[(temp_sample->bits==8?1:2)*temp_sample->len];
13612 14790 customsfxdata[j].data = calloc((temp_sample->bits==8?1:2)*(temp_sample->stereo == 0 ? 1 : 2)*temp_sample->len,1);
13613 14790 customsfxdata[j].bits = temp_sample->bits;
13614 14790 customsfxdata[j].stereo = temp_sample->stereo;
13615 14790 customsfxdata[j].freq = temp_sample->freq;
13616 14790 customsfxdata[j].priority = temp_sample->priority;
13617 14790 customsfxdata[j].len = temp_sample->len;
13618 14790 customsfxdata[j].loop_start = temp_sample->loop_start;
13619 14790 customsfxdata[j].loop_end = temp_sample->loop_end;
13620 14790 customsfxdata[j].param = temp_sample->param;
13621 14790 memcpy(customsfxdata[j].data, (temp_sample->data), (temp_sample->bits==8?1:2)*(temp_sample->stereo==0 ? 1 : 2)*temp_sample->len);
13622 14790 i=j;
13623 14790 }
13624 58 }
13625
13626 extern char *guy_string[eMAXGUYS];
13627 extern const char *old_guy_string[OLDMAXGUYS];
13628
13629 58 int32_t readguys(PACKFILE *f, zquestheader *Header, bool keepdata)
13630 {
13631 dword dummy;
13632 word guy_cversion;
13633 58 word guyversion=0;
13634
13635
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 if(Header->zelda_version >= 0x193)
13636 {
13637 //section version info
13638
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(!p_igetw(&guyversion,f,true))
13639 {
13640 return qe_invalid;
13641 }
13642
13643 58 FFCore.quest_format[vGuys] = guyversion;
13644
13645 //al_trace("Guys version %d\n", guyversion);
13646
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(!p_igetw(&guy_cversion,f,true))
13647 {
13648 return qe_invalid;
13649 }
13650 58 al_trace("Guy CVersion is: %d\n", guy_cversion);
13651 //section size
13652
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(!p_igetl(&dummy,f,true))
13653 {
13654 return qe_invalid;
13655 }
13656 58 }
13657
13658
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(guyversion > 3)
13659 {
13660
2/2
✓ Branch 0 taken 29696 times.
✓ Branch 1 taken 58 times.
29754 for(int32_t i=0; i<MAXGUYS; i++)
13661 {
13662 char tempname[64];
13663
13664 // rev. 1511 : guyversion = 23. upped to 512 editable enemies. -Gleeok
13665 // if guyversion < 23 then there is only 256 enemies in the packfile, so default the rest.
13666
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 29696 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
29696 if(guyversion < 23 && i >= OLDBETAMAXGUYS && keepdata)
13667 {
13668 memset(tempname, 0, sizeof(char)*64);
13669 sprintf(tempname, "e%03d", i);
13670 strcpy(guy_string[i], tempname);
13671
13672 continue;
13673 }
13674
13675
1/2
✓ Branch 0 taken 29696 times.
✗ Branch 1 not taken.
29696 if(!pfread(tempname, 64, f, keepdata))
13676 {
13677 return qe_invalid;
13678 }
13679
13680 // Don't retain names of uneditable enemy entries!
13681
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29696 times.
29696 if(keepdata)
13682 {
13683 // for version upgrade to 2.5
13684
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 29696 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
29696 if(guyversion < 23 && i >= 177)
13685 {
13686 // some of the older builds have names such as 'zz123',
13687 // (this order gets messed up with some eXXX and some zzXXX)
13688 // so let's update to the newer naming convection. -Gleeok
13689 char tmpbuf[64];
13690 memset(tmpbuf, 0, sizeof(char)*64);
13691 sprintf(tmpbuf, "zz%03d", i);
13692
13693 if(memcmp(tempname, tmpbuf, size_t(5)) == 0)
13694 {
13695 memset(tempname, 0, sizeof(char)*64);
13696 sprintf(tempname, "e%03d", i);
13697 }
13698 }
13699
13700
6/6
✓ Branch 0 taken 10266 times.
✓ Branch 1 taken 19430 times.
✓ Branch 2 taken 9744 times.
✓ Branch 3 taken 522 times.
✓ Branch 4 taken 7694 times.
✓ Branch 5 taken 2050 times.
29696 if(i >= OLDMAXGUYS || strlen(tempname)<1 || tempname[strlen(tempname)-1]!=' ')
13701 {
13702 27646 strcpy(guy_string[i], tempname);
13703 27646 }
13704 else
13705 {
13706 2050 strcpy(guy_string[i],old_guy_string[i]);
13707 }
13708 29696 }
13709 29696 }
13710 58 }
13711 else
13712 {
13713 if(keepdata)
13714 {
13715 for(int32_t i=0; i<eMAXGUYS; i++)
13716 {
13717 sprintf(guy_string[i],"zz%03d",i);
13718 }
13719
13720 for(int32_t i=0; i<OLDMAXGUYS; i++)
13721 {
13722 strcpy(guy_string[i],old_guy_string[i]);
13723 }
13724 }
13725 }
13726
13727
13728 //finally... section data
13729
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 if(keepdata)
13730 {
13731 58 init_guys(guyversion); //using default data for now...
13732
13733 // Goriya guy fix
13734
2/6
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 58 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
58 if((Header->zelda_version < 0x211)||((Header->zelda_version == 0x211)&&(Header->build<7)))
13735 {
13736 if(get_bit(quest_rules,qr_NEWENEMYTILES))
13737 {
13738 guysbuf[gGORIYA].tile=130;
13739 guysbuf[gGORIYA].e_tile=130;
13740 }
13741 }
13742 58 }
13743
13744
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(Header->zelda_version < 0x193)
13745 {
13746 if(get_bit(deprecated_rules,46))
13747 {
13748 guysbuf[eDODONGO].cset=14;
13749 guysbuf[eDODONGO].bosspal=spDIG;
13750 }
13751 }
13752 // Not sure when this first changed, but it's necessary for 2.10, at least
13753 // @TODO: @BUG:1.92 - 1.84? Figure this out exactly for the final 2.50 release.
13754 //2.10 Fixes
13755
2/6
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 58 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
58 if((Header->zelda_version < 0x211)||((Header->zelda_version == 0x211)&&(Header->build<18)))
13756 {
13757 guysbuf[eWWIZ].editorflags |= ENEMY_FLAG5;
13758 guysbuf[eMOLDORM].editorflags |= ENEMY_FLAG6;
13759 guysbuf[eMANHAN].editorflags |= ENEMY_FLAG6;
13760 guysbuf[eCENT1].misc3 = 1;
13761 guysbuf[eCENT2].misc3 = 1;
13762 }
13763
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
58 if((Header->zelda_version <= 0x255) || (Header->zelda_version == 0x255 && Header->build < 47) )
13764 {
13765 58 guysbuf[eWPOLSV].defense[edefWhistle] = ed1HKO;
13766 58 }
13767
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(Header->zelda_version <= 0x210)
13768 {
13769 guysbuf[eGLEEOK1F].misc6 = 16;
13770 guysbuf[eGLEEOK2F].misc6 = 16;
13771 guysbuf[eGLEEOK3F].misc6 = 16;
13772 guysbuf[eGLEEOK4F].misc6 = 16;
13773
13774 guysbuf[eWIZ1].misc4 = 1; //only set the enemy that needs backward compat, not all of them.
13775 guysbuf[eBATROBE].misc4 = 1;
13776 //guysbuf[eSUMMONER].misc4 = 1;
13777 guysbuf[eWWIZ].misc4 = 1;
13778 guysbuf[eDODONGO].deadsfx = 15; //In 2.10 and earlier, Dodongos used this as their death sound.
13779 guysbuf[eDODONGOBS].deadsfx = 15; //In 2.10 and earlier, Dodongos used this as their death sound.
13780 }
13781
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(Header->zelda_version == 0x190)
13782 {
13783 al_trace("Setting Tribble Properties for Version: %x", Header->zelda_version);
13784 guysbuf[eKEESETRIB].misc3 = eVIRE; //1.90 and earlier, keese and gel tribbles grew up into
13785 guysbuf[eGELTRIB].misc3 = eZOL; //normal vires, and zols -Z (16th January, 2019 )
13786 }
13787
13788 // The versions here may not be correct
13789 // zelda_version>=0x211 handled at guyversion<24
13790
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 if(Header->zelda_version <= 0x190)
13791 {
13792 guysbuf[eCENT1].misc3 = 0;
13793 guysbuf[eCENT2].misc3 = 0;
13794 guysbuf[eMOLDORM].misc2 = 0;
13795 //guysbuf[eKEESETRIB].misc3 = eVIRE; //1.90 and earlier, keese and gel tribbles grew up into
13796 //guysbuf[eGELTRIB].misc3 = eZOL; //normal vires, and zols -Z (16th January, 2019 )
13797 }
13798
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 else if(Header->zelda_version <= 0x210)
13799 {
13800 guysbuf[eCENT1].misc3 = 1;
13801 guysbuf[eCENT2].misc3 = 1;
13802 guysbuf[eMOLDORM].misc2 = 0;
13803 }
13804
13805
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if ( Header->zelda_version < 0x211 ) //Default rest rates for phantom ghinis, peahats and keese in < 2.50 quests
13806 {
13807 guysbuf[eKEESE1].misc16 = 120;
13808 guysbuf[eKEESE2].misc16 = 120;
13809 guysbuf[eKEESE3].misc16 = 120;
13810 guysbuf[eKEESETRIB].misc16 = 120;
13811 guysbuf[eKEESE1].misc17 = 16;
13812 guysbuf[eKEESE2].misc17 = 16;
13813 guysbuf[eKEESE3].misc17 = 16;
13814 guysbuf[eKEESETRIB].misc17 = 16;
13815
13816 guysbuf[ePEAHAT].misc16 = 80;
13817 guysbuf[ePEAHAT].misc17 = 16;
13818
13819 guysbuf[eGHINI2].misc16 = 120;
13820 guysbuf[eGHINI2].misc17 = 10;
13821
13822 }
13823
13824
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 if(guyversion<=2)
13825 {
13826 return readherosprites2(f, guyversion==2?0:-1, 0, keepdata);
13827 }
13828
13829
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 if(guyversion > 3)
13830 {
13831 guydata tempguy;
13832
13833
2/2
✓ Branch 0 taken 29696 times.
✓ Branch 1 taken 58 times.
29754 for(int32_t i=0; i<MAXGUYS; i++)
13834 {
13835
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 29696 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
29696 if(guyversion < 23 && keepdata) // May 2012 : 512 max enemies
13836 {
13837 if(i >= OLDBETAMAXGUYS)
13838 {
13839 memset(&guysbuf[i], 0, sizeof(guydata));
13840 continue;
13841 }
13842 }
13843
13844 29696 memset(&tempguy, 0, sizeof(guydata));
13845
13846
1/2
✓ Branch 0 taken 29696 times.
✗ Branch 1 not taken.
29696 if(!p_igetl(&(tempguy.flags),f,keepdata))
13847 {
13848 return qe_invalid;
13849 }
13850
13851
1/2
✓ Branch 0 taken 29696 times.
✗ Branch 1 not taken.
29696 if(!p_igetl(&(tempguy.flags2),f,keepdata))
13852 {
13853 return qe_invalid;
13854 }
13855
13856
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 28160 times.
29696 if ( guyversion >= 36 ) //expanded tiles
13857 {
13858
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(!p_igetl(&(tempguy.tile),f,keepdata))
13859 {
13860 return qe_invalid;
13861 }
13862 1536 }
13863 else
13864 {
13865
1/2
✓ Branch 0 taken 28160 times.
✗ Branch 1 not taken.
28160 if(!p_igetw(&(tempguy.tile),f,keepdata))
13866 {
13867 return qe_invalid;
13868 }
13869 }
13870
1/2
✓ Branch 0 taken 29696 times.
✗ Branch 1 not taken.
29696 if(!p_getc(&(tempguy.width),f,keepdata))
13871 {
13872 return qe_invalid;
13873 }
13874
13875
1/2
✓ Branch 0 taken 29696 times.
✗ Branch 1 not taken.
29696 if(!p_getc(&(tempguy.height),f,keepdata))
13876 {
13877 return qe_invalid;
13878 }
13879
13880
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 28160 times.
29696 if ( guyversion >= 36 ) //expanded tiles
13881 {
13882
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(!p_igetl(&(tempguy.s_tile),f,keepdata))
13883 {
13884 return qe_invalid;
13885 }
13886 1536 }
13887 else
13888 {
13889
1/2
✓ Branch 0 taken 28160 times.
✗ Branch 1 not taken.
28160 if(!p_igetw(&(tempguy.s_tile),f,keepdata))
13890 {
13891 return qe_invalid;
13892 }
13893 }
13894
13895
1/2
✓ Branch 0 taken 29696 times.
✗ Branch 1 not taken.
29696 if(!p_getc(&(tempguy.s_width),f,keepdata))
13896 {
13897 return qe_invalid;
13898 }
13899
13900
1/2
✓ Branch 0 taken 29696 times.
✗ Branch 1 not taken.
29696 if(!p_getc(&(tempguy.s_height),f,keepdata))
13901 {
13902 return qe_invalid;
13903 }
13904
13905
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 28160 times.
29696 if ( guyversion >= 36 ) //expanded tiles
13906 {
13907
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(!p_igetl(&(tempguy.e_tile),f,keepdata))
13908 {
13909 return qe_invalid;
13910 }
13911 1536 }
13912 else
13913 {
13914
1/2
✓ Branch 0 taken 28160 times.
✗ Branch 1 not taken.
28160 if(!p_igetw(&(tempguy.e_tile),f,keepdata))
13915 {
13916 return qe_invalid;
13917 }
13918 }
13919
13920
1/2
✓ Branch 0 taken 29696 times.
✗ Branch 1 not taken.
29696 if(!p_getc(&(tempguy.e_width),f,keepdata))
13921 {
13922 return qe_invalid;
13923 }
13924
13925
1/2
✓ Branch 0 taken 29696 times.
✗ Branch 1 not taken.
29696 if(!p_getc(&(tempguy.e_height),f,keepdata))
13926 {
13927 return qe_invalid;
13928 }
13929
13930
1/2
✓ Branch 0 taken 29696 times.
✗ Branch 1 not taken.
29696 if(!p_igetw(&(tempguy.hp),f,keepdata))
13931 {
13932 return qe_invalid;
13933 }
13934
13935
1/2
✓ Branch 0 taken 29696 times.
✗ Branch 1 not taken.
29696 if(!p_igetw(&(tempguy.family),f,keepdata))
13936 {
13937 return qe_invalid;
13938 }
13939
13940
1/12
✗ Branch 0 not taken.
✓ Branch 1 taken 29696 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
29696 if(guyversion < 9 && (i==eDKNUT1 || i==eDKNUT2 || i==eDKNUT3 || i==eDKNUT4 || i==eDKNUT5)) // Whoops, forgot about Darknuts...
13941 {
13942 if(get_bit(quest_rules,qr_NEWENEMYTILES))
13943 {
13944 tempguy.s_tile=tempguy.e_tile+120;
13945 tempguy.s_width=tempguy.e_width;
13946 tempguy.s_height=tempguy.e_height;
13947 }
13948 else tempguy.s_tile=860;
13949 }
13950
13951
1/2
✓ Branch 0 taken 29696 times.
✗ Branch 1 not taken.
29696 if(!p_igetw(&(tempguy.cset),f,keepdata))
13952 {
13953 return qe_invalid;
13954 }
13955
13956
1/2
✓ Branch 0 taken 29696 times.
✗ Branch 1 not taken.
29696 if(!p_igetw(&(tempguy.anim),f,keepdata))
13957 {
13958 return qe_invalid;
13959 }
13960
13961
1/2
✓ Branch 0 taken 29696 times.
✗ Branch 1 not taken.
29696 if(!p_igetw(&(tempguy.e_anim),f,keepdata))
13962 {
13963 return qe_invalid;
13964 }
13965
13966
1/2
✓ Branch 0 taken 29696 times.
✗ Branch 1 not taken.
29696 if(!p_igetw(&(tempguy.frate),f,keepdata))
13967 {
13968 return qe_invalid;
13969 }
13970
13971
1/2
✓ Branch 0 taken 29696 times.
✗ Branch 1 not taken.
29696 if(!p_igetw(&(tempguy.e_frate),f,keepdata))
13972 {
13973 return qe_invalid;
13974 }
13975
13976
1/2
✓ Branch 0 taken 29696 times.
✗ Branch 1 not taken.
29696 if(guyversion < 13) // April 2009
13977 {
13978 if(get_bit(deprecated_rules, qr_SLOWENEMYANIM_DEP))
13979 {
13980 tempguy.frate *= 2;
13981 tempguy.e_frate *= 2;
13982 }
13983 }
13984
13985
1/2
✓ Branch 0 taken 29696 times.
✗ Branch 1 not taken.
29696 if(guyversion < 14) // May 1 2009
13986 {
13987 if(tempguy.anim==a2FRMSLOW)
13988 {
13989 tempguy.anim=a2FRM;
13990 tempguy.frate *= 2;
13991 }
13992
13993 if(tempguy.e_anim==a2FRMSLOW)
13994 {
13995 tempguy.e_anim=a2FRM;
13996 tempguy.e_frate *= 2;
13997 }
13998
13999 if(tempguy.anim==aFLIPSLOW)
14000 {
14001 tempguy.anim=aFLIP;
14002 tempguy.frate *= 2;
14003 }
14004
14005 if(tempguy.e_anim==aFLIPSLOW)
14006 {
14007 tempguy.e_anim=aFLIP;
14008 tempguy.e_frate *= 2;
14009 }
14010
14011 if(tempguy.anim == aNEWDWALK) tempguy.anim = a4FRM4DIR;
14012
14013 if(tempguy.e_anim == aNEWDWALK) tempguy.e_anim = a4FRM4DIR;
14014
14015 if(tempguy.anim == aNEWPOLV || tempguy.anim == a4FRM3TRAP)
14016 {
14017 tempguy.anim=a4FRM4DIR;
14018 tempguy.s_tile=(get_bit(quest_rules,qr_NEWENEMYTILES) ? tempguy.e_tile : tempguy.tile)+20;
14019 }
14020
14021 if(tempguy.e_anim == aNEWPOLV || tempguy.e_anim == a4FRM3TRAP)
14022 {
14023 tempguy.e_anim=a4FRM4DIR;
14024 tempguy.s_tile=(get_bit(quest_rules,qr_NEWENEMYTILES) ? tempguy.e_tile : tempguy.tile)+20;
14025 }
14026 }
14027
14028
1/2
✓ Branch 0 taken 29696 times.
✗ Branch 1 not taken.
29696 if(!p_igetw(&(tempguy.dp),f,keepdata))
14029 {
14030 return qe_invalid;
14031 }
14032
14033 //correction for guy fire
14034
1/2
✓ Branch 0 taken 29696 times.
✗ Branch 1 not taken.
29696 if(guyversion < 6)
14035 {
14036 if(i == gFIRE)
14037 tempguy.dp = 2;
14038 }
14039
14040
1/2
✓ Branch 0 taken 29696 times.
✗ Branch 1 not taken.
29696 if(!p_igetw(&(tempguy.wdp),f,keepdata))
14041 {
14042 return qe_invalid;
14043 }
14044
14045
1/2
✓ Branch 0 taken 29696 times.
✗ Branch 1 not taken.
29696 if(!p_igetw(&(tempguy.weapon),f,keepdata))
14046 {
14047 return qe_invalid;
14048 }
14049
14050 //correction for bosses using triple, "rising" fireballs
14051
1/2
✓ Branch 0 taken 29696 times.
✗ Branch 1 not taken.
29696 if(guyversion < 5)
14052 {
14053 if(i == eLAQUAM || i == eRAQUAM || i == eGOHMA1 || i == eGOHMA2 ||
14054 i == eGOHMA3 || i == eGOHMA4)
14055 {
14056 if(tempguy.weapon == ewFireball)
14057 tempguy.weapon = ewFireball2;
14058 }
14059 }
14060
14061
1/2
✓ Branch 0 taken 29696 times.
✗ Branch 1 not taken.
29696 if(!p_igetw(&(tempguy.rate),f,keepdata))
14062 {
14063 return qe_invalid;
14064 }
14065
14066
1/2
✓ Branch 0 taken 29696 times.
✗ Branch 1 not taken.
29696 if(!p_igetw(&(tempguy.hrate),f,keepdata))
14067 {
14068 return qe_invalid;
14069 }
14070
14071
1/2
✓ Branch 0 taken 29696 times.
✗ Branch 1 not taken.
29696 if(!p_igetw(&(tempguy.step),f,keepdata))
14072 {
14073 return qe_invalid;
14074 }
14075
14076 // HIGHLY UNORTHODOX UPDATING THING, part 2
14077
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 29696 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
29696 if(fixpolsvoice && tempguy.family==eePOLSV)
14078 {
14079 tempguy.step /= 2;
14080 }
14081
14082
1/2
✓ Branch 0 taken 29696 times.
✗ Branch 1 not taken.
29696 if(!p_igetw(&(tempguy.homing),f,keepdata))
14083 {
14084 return qe_invalid;
14085 }
14086
14087
1/2
✓ Branch 0 taken 29696 times.
✗ Branch 1 not taken.
29696 if(!p_igetw(&(tempguy.grumble),f,keepdata))
14088 {
14089 return qe_invalid;
14090 }
14091
14092
1/2
✓ Branch 0 taken 29696 times.
✗ Branch 1 not taken.
29696 if(!p_igetw(&(tempguy.item_set),f,keepdata))
14093 {
14094 return qe_invalid;
14095 }
14096
14097
1/2
✓ Branch 0 taken 29696 times.
✗ Branch 1 not taken.
29696 if(guyversion>=22) // Version 22: Expand misc attributes to 32 bits
14098 {
14099
1/2
✓ Branch 0 taken 29696 times.
✗ Branch 1 not taken.
29696 if(!p_igetl(&(tempguy.misc1),f,keepdata))
14100 {
14101 return qe_invalid;
14102 }
14103
14104
1/2
✓ Branch 0 taken 29696 times.
✗ Branch 1 not taken.
29696 if(!p_igetl(&(tempguy.misc2),f,keepdata))
14105 {
14106 return qe_invalid;
14107 }
14108
14109
1/2
✓ Branch 0 taken 29696 times.
✗ Branch 1 not taken.
29696 if(!p_igetl(&(tempguy.misc3),f,keepdata))
14110 {
14111 return qe_invalid;
14112 }
14113
14114
1/2
✓ Branch 0 taken 29696 times.
✗ Branch 1 not taken.
29696 if(!p_igetl(&(tempguy.misc4),f,keepdata))
14115 {
14116 return qe_invalid;
14117 }
14118
14119
1/2
✓ Branch 0 taken 29696 times.
✗ Branch 1 not taken.
29696 if(!p_igetl(&(tempguy.misc5),f,keepdata))
14120 {
14121 return qe_invalid;
14122 }
14123
14124
1/2
✓ Branch 0 taken 29696 times.
✗ Branch 1 not taken.
29696 if(!p_igetl(&(tempguy.misc6),f,keepdata))
14125 {
14126 return qe_invalid;
14127 }
14128
14129
1/2
✓ Branch 0 taken 29696 times.
✗ Branch 1 not taken.
29696 if(!p_igetl(&(tempguy.misc7),f,keepdata))
14130 {
14131 return qe_invalid;
14132 }
14133
14134
1/2
✓ Branch 0 taken 29696 times.
✗ Branch 1 not taken.
29696 if(!p_igetl(&(tempguy.misc8),f,keepdata))
14135 {
14136 return qe_invalid;
14137 }
14138
14139
1/2
✓ Branch 0 taken 29696 times.
✗ Branch 1 not taken.
29696 if(!p_igetl(&(tempguy.misc9),f,keepdata))
14140 {
14141 return qe_invalid;
14142 }
14143
14144
1/2
✓ Branch 0 taken 29696 times.
✗ Branch 1 not taken.
29696 if(!p_igetl(&(tempguy.misc10),f,keepdata))
14145 {
14146 return qe_invalid;
14147 }
14148 29696 }
14149 else
14150 {
14151 int16_t tempMisc;
14152
14153 if(!p_igetw(&tempMisc,f,keepdata))
14154 {
14155 return qe_invalid;
14156 }
14157
14158 tempguy.misc1=tempMisc;
14159
14160 if(!p_igetw(&tempMisc,f,keepdata))
14161 {
14162 return qe_invalid;
14163 }
14164
14165 tempguy.misc2=tempMisc;
14166
14167 if(!p_igetw(&tempMisc,f,keepdata))
14168 {
14169 return qe_invalid;
14170 }
14171
14172 tempguy.misc3=tempMisc;
14173
14174 if(!p_igetw(&tempMisc,f,keepdata))
14175 {
14176 return qe_invalid;
14177 }
14178
14179 tempguy.misc4=tempMisc;
14180
14181 if(!p_igetw(&tempMisc,f,keepdata))
14182 {
14183 return qe_invalid;
14184 }
14185
14186 tempguy.misc5=tempMisc;
14187
14188 if(guyversion < 13) // April 2009 - a tiny Wizzrobe update
14189 {
14190 if(tempguy.family == eeWIZZ && !(tempguy.misc1))
14191 tempguy.misc5 = 74;
14192 }
14193
14194 if(!p_igetw(&tempMisc,f,keepdata))
14195 {
14196 return qe_invalid;
14197 }
14198
14199 tempguy.misc6=tempMisc;
14200
14201 if(!p_igetw(&tempMisc,f,keepdata))
14202 {
14203 return qe_invalid;
14204 }
14205
14206 tempguy.misc7=tempMisc;
14207
14208 if(!p_igetw(&tempMisc,f,keepdata))
14209 {
14210 return qe_invalid;
14211 }
14212
14213 tempguy.misc8=tempMisc;
14214
14215 if(!p_igetw(&tempMisc,f,keepdata))
14216 {
14217 return qe_invalid;
14218 }
14219
14220 tempguy.misc9=tempMisc;
14221
14222 if(!p_igetw(&tempMisc,f,keepdata))
14223 {
14224 return qe_invalid;
14225 }
14226
14227 tempguy.misc10=tempMisc;
14228 }
14229
14230
1/2
✓ Branch 0 taken 29696 times.
✗ Branch 1 not taken.
29696 if(!p_igetw(&(tempguy.bgsfx),f,keepdata))
14231 {
14232 return qe_invalid;
14233 }
14234
14235
1/2
✓ Branch 0 taken 29696 times.
✗ Branch 1 not taken.
29696 if(!p_igetw(&(tempguy.bosspal),f,keepdata))
14236 {
14237 return qe_invalid;
14238 }
14239
14240
1/2
✓ Branch 0 taken 29696 times.
✗ Branch 1 not taken.
29696 if(!p_igetw(&(tempguy.extend),f,keepdata))
14241 {
14242 return qe_invalid;
14243 }
14244
14245 //! Enemy Defences
14246
14247 //If a 2.50 quest, use only the 2.5 defences.
14248
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29696 times.
29696 if(guyversion >= 16 ) // November 2009 - Super Enemy Editor
14249 {
14250
2/2
✓ Branch 0 taken 564224 times.
✓ Branch 1 taken 29696 times.
593920 for(int32_t j=0; j<edefLAST; j++)
14251 {
14252
1/2
✓ Branch 0 taken 564224 times.
✗ Branch 1 not taken.
564224 if(!p_getc(&(tempguy.defense[j]),f,keepdata))
14253 {
14254 return qe_invalid;
14255 }
14256 564224 }
14257 //then copy the generic script defence to all the new script defences
14258
14259 29696 }
14260
14261
14262
14263
14264
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29696 times.
29696 if(guyversion >= 18)
14265 {
14266
1/2
✓ Branch 0 taken 29696 times.
✗ Branch 1 not taken.
29696 if(!p_getc(&(tempguy.hitsfx),f,keepdata))
14267 {
14268 return qe_invalid;
14269 }
14270
14271
1/2
✓ Branch 0 taken 29696 times.
✗ Branch 1 not taken.
29696 if(!p_getc(&(tempguy.deadsfx),f,keepdata))
14272 {
14273 return qe_invalid;
14274 }
14275 29696 }
14276
14277
1/2
✓ Branch 0 taken 29696 times.
✗ Branch 1 not taken.
29696 if(guyversion >= 22)
14278 {
14279
1/2
✓ Branch 0 taken 29696 times.
✗ Branch 1 not taken.
29696 if(!p_igetl(&(tempguy.misc11),f,keepdata))
14280 {
14281 return qe_invalid;
14282 }
14283
14284
1/2
✓ Branch 0 taken 29696 times.
✗ Branch 1 not taken.
29696 if(!p_igetl(&(tempguy.misc12),f,keepdata))
14285 {
14286 return qe_invalid;
14287 }
14288 29696 }
14289 else if(guyversion >= 19)
14290 {
14291 int16_t tempMisc;
14292
14293 if(!p_igetw(&tempMisc,f,keepdata))
14294 {
14295 return qe_invalid;
14296 }
14297
14298 tempguy.misc11=tempMisc;
14299
14300 if(!p_igetw(&tempMisc,f,keepdata))
14301 {
14302 return qe_invalid;
14303 }
14304
14305 tempguy.misc12=tempMisc;
14306 }
14307
14308 //If a 2.54 or later quest, use all of the defences.
14309
2/2
✓ Branch 0 taken 28160 times.
✓ Branch 1 taken 1536 times.
29696 if(guyversion > 24) // Add new guyversion conditional statement
14310 {
14311
2/2
✓ Branch 0 taken 33792 times.
✓ Branch 1 taken 1536 times.
35328 for(int32_t j=edefLAST; j<edefLAST255; j++)
14312 {
14313
1/2
✓ Branch 0 taken 33792 times.
✗ Branch 1 not taken.
33792 if(!p_getc(&(tempguy.defense[j]),f,keepdata))
14314 {
14315 return qe_invalid;
14316 }
14317 33792 }
14318 1536 }
14319
14320
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 28160 times.
29696 if(guyversion <= 24) // Port over generic script settings from old quests in the new editor.
14321 {
14322
2/2
✓ Branch 0 taken 281600 times.
✓ Branch 1 taken 28160 times.
309760 for(int32_t j=edefSCRIPT01; j<=edefSCRIPT10; j++)
14323 {
14324 281600 tempguy.defense[j] = tempguy.defense[edefSCRIPT] ;
14325 281600 }
14326 28160 }
14327
14328 //tilewidth, tileheight, hitwidth, hitheight, hitzheight, hitxofs, hityofs, hitzofs
14329
2/2
✓ Branch 0 taken 28160 times.
✓ Branch 1 taken 1536 times.
29696 if(guyversion > 25)
14330 {
14331
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(!p_igetl(&(tempguy.txsz),f,keepdata))
14332 {
14333 return qe_invalid;
14334 }
14335
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(!p_igetl(&(tempguy.tysz),f,keepdata))
14336 {
14337 return qe_invalid;
14338 }
14339
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(!p_igetl(&(tempguy.hxsz),f,keepdata))
14340 {
14341 return qe_invalid;
14342 }
14343
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(!p_igetl(&(tempguy.hysz),f,keepdata))
14344 {
14345 return qe_invalid;
14346 }
14347
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(!p_igetl(&(tempguy.hzsz),f,keepdata))
14348 {
14349 return qe_invalid;
14350 }
14351 /* Is it safe to read a fixed with getl, or do I need to typecast it? -Z
14352
14353 */
14354 1536 }
14355 //More Enemy Editor vars for 2.60
14356
2/2
✓ Branch 0 taken 28160 times.
✓ Branch 1 taken 1536 times.
29696 if(guyversion > 26)
14357 {
14358
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(!p_igetl(&(tempguy.hxofs),f,keepdata))
14359 {
14360 return qe_invalid;
14361 }
14362
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(!p_igetl(&(tempguy.hyofs),f,keepdata))
14363 {
14364 return qe_invalid;
14365 }
14366
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(!p_igetl(&(tempguy.xofs),f,keepdata))
14367 {
14368 return qe_invalid;
14369 }
14370
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(!p_igetl(&(tempguy.yofs),f,keepdata))
14371 {
14372 return qe_invalid;
14373 }
14374
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(!p_igetl(&(tempguy.zofs),f,keepdata))
14375 {
14376 return qe_invalid;
14377 }
14378 1536 }
14379
14380
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 28160 times.
29696 if(guyversion <= 27) // Port over generic script settings from old quests in the new editor.
14381 {
14382 28160 tempguy.wpnsprite = 0;
14383 28160 }
14384
14385
2/2
✓ Branch 0 taken 28160 times.
✓ Branch 1 taken 1536 times.
29696 if(guyversion > 27)
14386 {
14387
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(!p_igetl(&(tempguy.wpnsprite),f,keepdata))
14388 {
14389 return qe_invalid;
14390 }
14391 1536 }
14392
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 28160 times.
29696 if(guyversion <= 28) // Port over generic script settings from old quests in the new editor.
14393 {
14394 28160 tempguy.SIZEflags = 0;
14395 28160 }
14396
2/2
✓ Branch 0 taken 28160 times.
✓ Branch 1 taken 1536 times.
29696 if(guyversion > 28)
14397 {
14398
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(!p_igetl(&(tempguy.SIZEflags),f,keepdata))
14399 {
14400 return qe_invalid;
14401 }
14402
14403 1536 }
14404
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 28160 times.
29696 if(guyversion < 30) // Port over generic script settings from old quests in the new editor.
14405 {
14406 28160 tempguy.frozentile = 0;
14407 28160 tempguy.frozencset = 0;
14408 28160 tempguy.frozenclock = 0;
14409
2/2
✓ Branch 0 taken 281600 times.
✓ Branch 1 taken 28160 times.
309760 for ( int32_t q = 0; q < 10; q++ ) tempguy.frozenmisc[q] = 0;
14410 28160 }
14411
2/2
✓ Branch 0 taken 28160 times.
✓ Branch 1 taken 1536 times.
29696 if(guyversion >= 30)
14412 {
14413
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(!p_igetl(&(tempguy.frozentile),f,keepdata))
14414 {
14415 return qe_invalid;
14416 }
14417
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(!p_igetl(&(tempguy.frozencset),f,keepdata))
14418 {
14419 return qe_invalid;
14420 }
14421
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(!p_igetl(&(tempguy.frozenclock),f,keepdata))
14422 {
14423 return qe_invalid;
14424 }
14425
2/2
✓ Branch 0 taken 15360 times.
✓ Branch 1 taken 1536 times.
16896 for ( int32_t q = 0; q < 10; q++ ) {
14426
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if(!p_igetw(&(tempguy.frozenmisc[q]),f,keepdata))
14427 {
14428 return qe_invalid;
14429 }
14430 15360 }
14431
14432 1536 }
14433
14434
2/2
✓ Branch 0 taken 28160 times.
✓ Branch 1 taken 1536 times.
29696 if(guyversion >= 34)
14435 {
14436
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(!p_igetw(&(tempguy.firesfx),f,keepdata))
14437 {
14438 return qe_invalid;
14439 }
14440
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(!p_igetl(&(tempguy.misc16),f,keepdata))
14441 {
14442 return qe_invalid;
14443 }
14444
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(!p_igetl(&(tempguy.misc17),f,keepdata))
14445 {
14446 return qe_invalid;
14447 }
14448
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(!p_igetl(&(tempguy.misc18),f,keepdata))
14449 {
14450 return qe_invalid;
14451 }
14452
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(!p_igetl(&(tempguy.misc19),f,keepdata))
14453 {
14454 return qe_invalid;
14455 }
14456
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(!p_igetl(&(tempguy.misc20),f,keepdata))
14457 {
14458 return qe_invalid;
14459 }
14460
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(!p_igetl(&(tempguy.misc21),f,keepdata))
14461 {
14462 return qe_invalid;
14463 }
14464
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(!p_igetl(&(tempguy.misc22),f,keepdata))
14465 {
14466 return qe_invalid;
14467 }
14468
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(!p_igetl(&(tempguy.misc23),f,keepdata))
14469 {
14470 return qe_invalid;
14471 }
14472
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(!p_igetl(&(tempguy.misc24),f,keepdata))
14473 {
14474 return qe_invalid;
14475 }
14476
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(!p_igetl(&(tempguy.misc25),f,keepdata))
14477 {
14478 return qe_invalid;
14479 }
14480
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(!p_igetl(&(tempguy.misc26),f,keepdata))
14481 {
14482 return qe_invalid;
14483 }
14484
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(!p_igetl(&(tempguy.misc27),f,keepdata))
14485 {
14486 return qe_invalid;
14487 }
14488
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(!p_igetl(&(tempguy.misc28),f,keepdata))
14489 {
14490 return qe_invalid;
14491 }
14492
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(!p_igetl(&(tempguy.misc29),f,keepdata))
14493 {
14494 return qe_invalid;
14495 }
14496
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(!p_igetl(&(tempguy.misc30),f,keepdata))
14497 {
14498 return qe_invalid;
14499 }
14500
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(!p_igetl(&(tempguy.misc31),f,keepdata))
14501 {
14502 return qe_invalid;
14503 }
14504
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(!p_igetl(&(tempguy.misc32),f,keepdata))
14505 {
14506 return qe_invalid;
14507 }
14508
14509
2/2
✓ Branch 0 taken 49152 times.
✓ Branch 1 taken 1536 times.
50688 for ( int32_t q = 0; q < 32; q++ ) {
14510
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_igetl(&(tempguy.movement[q]),f,keepdata))
14511 {
14512 return qe_invalid;
14513 }
14514 49152 }
14515
2/2
✓ Branch 0 taken 49152 times.
✓ Branch 1 taken 1536 times.
50688 for ( int32_t q = 0; q < 32; q++ ) {
14516
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_igetl(&(tempguy.new_weapon[q]),f,keepdata))
14517 {
14518 return qe_invalid;
14519 }
14520 49152 }
14521
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(!p_igetw(&(tempguy.script),f,keepdata))
14522 {
14523 return qe_invalid;
14524 }
14525 //al_trace("NPC Script ID is: %d\n",tempguy.script);
14526
2/2
✓ Branch 0 taken 12288 times.
✓ Branch 1 taken 1536 times.
13824 for ( int32_t q = 0; q < 8; q++ )
14527 {
14528
1/2
✓ Branch 0 taken 12288 times.
✗ Branch 1 not taken.
12288 if(!p_igetl(&(tempguy.initD[q]),f,keepdata))
14529 {
14530 return qe_invalid;
14531 }
14532 12288 }
14533
2/2
✓ Branch 0 taken 3072 times.
✓ Branch 1 taken 1536 times.
4608 for ( int32_t q = 0; q < 2; q++ )
14534 {
14535
1/2
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
3072 if(!p_igetl(&(tempguy.initA[q]),f,keepdata))
14536 {
14537 return qe_invalid;
14538 }
14539 3072 }
14540
14541 1536 }
14542
14543
2/2
✓ Branch 0 taken 28160 times.
✓ Branch 1 taken 1536 times.
29696 if(guyversion >= 37)
14544 {
14545
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(!p_igetl(&(tempguy.editorflags),f,keepdata))
14546 {
14547 return qe_invalid;
14548 }
14549 1536 }
14550
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 28160 times.
29696 if ( guyversion < 37 ) { tempguy.editorflags = 0; }
14551
2/2
✓ Branch 0 taken 28160 times.
✓ Branch 1 taken 1536 times.
29696 if(guyversion >= 38)
14552 {
14553
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(!p_igetl(&(tempguy.misc13),f,keepdata))
14554 {
14555 return qe_invalid;
14556 }
14557
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(!p_igetl(&(tempguy.misc14),f,keepdata))
14558 {
14559 return qe_invalid;
14560 }
14561
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(!p_igetl(&(tempguy.misc15),f,keepdata))
14562 {
14563 return qe_invalid;
14564 }
14565
14566 1536 }
14567
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 28160 times.
29696 if ( guyversion < 38 )
14568 {
14569 28160 tempguy.misc13 = 0;
14570 28160 tempguy.misc14 = 0;
14571 28160 tempguy.misc15 = 0;
14572 28160 }
14573
14574
2/2
✓ Branch 0 taken 28160 times.
✓ Branch 1 taken 1536 times.
29696 if ( guyversion >= 39 )
14575 {
14576
2/2
✓ Branch 0 taken 12288 times.
✓ Branch 1 taken 1536 times.
13824 for ( int32_t q = 0; q < 8; q++ )
14577 {
14578
2/2
✓ Branch 0 taken 798720 times.
✓ Branch 1 taken 12288 times.
811008 for ( int32_t w = 0; w < 65; w++ )
14579 {
14580
1/2
✓ Branch 0 taken 798720 times.
✗ Branch 1 not taken.
798720 if(!p_getc(&(tempguy.initD_label[q][w]),f,keepdata))
14581 {
14582 return qe_invalid;
14583 }
14584 798720 }
14585
2/2
✓ Branch 0 taken 798720 times.
✓ Branch 1 taken 12288 times.
811008 for ( int32_t w = 0; w < 65; w++ )
14586 {
14587
1/2
✓ Branch 0 taken 798720 times.
✗ Branch 1 not taken.
798720 if(!p_getc(&(tempguy.weapon_initD_label[q][w]),f,keepdata))
14588 {
14589 return qe_invalid;
14590 }
14591 798720 }
14592 12288 }
14593
14594
14595 1536 }
14596
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 28160 times.
29696 if ( guyversion < 39 ) //apply old InitD strings to both
14597 {
14598 28160 al_trace("Populating InitD Label Fields for NPCS\n");
14599
2/2
✓ Branch 0 taken 225280 times.
✓ Branch 1 taken 28160 times.
253440 for ( int32_t q = 0; q < 8; q++ )
14600 {
14601 225280 sprintf(tempguy.initD_label[q],"InitD[%d]",q);
14602 225280 sprintf(tempguy.weapon_initD_label[q],"InitD[%d]",q);
14603 225280 }
14604 28160 }
14605
2/2
✓ Branch 0 taken 28160 times.
✓ Branch 1 taken 1536 times.
29696 if ( guyversion >= 40 )
14606 {
14607
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(!p_igetw(&(tempguy.weaponscript),f,keepdata))
14608 {
14609 return qe_invalid;
14610 }
14611 1536 }
14612
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 28160 times.
29696 if ( guyversion < 40 )
14613 {
14614 28160 tempguy.weaponscript = 0;
14615 28160 }
14616 //eweapon script InitD
14617
2/2
✓ Branch 0 taken 28160 times.
✓ Branch 1 taken 1536 times.
29696 if ( guyversion >= 41 )
14618 {
14619
2/2
✓ Branch 0 taken 12288 times.
✓ Branch 1 taken 1536 times.
13824 for ( int32_t q = 0; q < 8; q++ )
14620 {
14621
1/2
✓ Branch 0 taken 12288 times.
✗ Branch 1 not taken.
12288 if(!p_igetl(&(tempguy.weap_initiald[q]),f,keepdata))
14622 {
14623 return qe_invalid;
14624 }
14625 12288 }
14626
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if ( guy_cversion < 4 )
14627 {
14628 if ( tempguy.family == eeKEESE )
14629 {
14630
14631 if ( !tempguy.misc1 )
14632 {
14633 tempguy.misc16 = 120;
14634 tempguy.misc17 = 16;
14635
14636 }
14637 }
14638 if ( tempguy.family == eePEAHAT )
14639 {
14640 tempguy.misc16 = 80;
14641 tempguy.misc17 = 16;
14642 }
14643
14644 if ( tempguy.family == eeGHINI )
14645 {
14646 tempguy.misc16 = 120;
14647 tempguy.misc17 = 10;
14648 }
14649
14650 }
14651 1536 }
14652
14653
14654
14655 //default weapon sprites (quest version < 2.54)
14656 //port over old defaults -Z
14657
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 28160 times.
29696 if(guyversion < 32)
14658 {
14659
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28160 times.
28160 if ( tempguy.wpnsprite <= 0 )
14660 {
14661
16/20
✗ Branch 0 not taken.
✓ Branch 1 taken 960 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 23301 times.
✓ Branch 4 taken 211 times.
✓ Branch 5 taken 237 times.
✓ Branch 6 taken 711 times.
✓ Branch 7 taken 347 times.
✓ Branch 8 taken 667 times.
✓ Branch 9 taken 55 times.
✓ Branch 10 taken 13 times.
✓ Branch 11 taken 97 times.
✓ Branch 12 taken 13 times.
✓ Branch 13 taken 256 times.
✓ Branch 14 taken 552 times.
✓ Branch 15 taken 75 times.
✓ Branch 16 taken 55 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 610 times.
28160 switch(tempguy.weapon)
14662 {
14663 case wNone:
14664 23301 tempguy.wpnsprite = 0; break;
14665
14666 case wSword:
14667 case wBeam:
14668 case wBrang:
14669 case wBomb:
14670 case wSBomb:
14671 case wLitBomb:
14672 case wLitSBomb:
14673 case wArrow:
14674 case wFire:
14675 case wWhistle:
14676 case wBait:
14677 case wWand:
14678 case wMagic:
14679 case wCatching:
14680 case wWind:
14681 case wRefMagic:
14682 case wRefFireball:
14683 case wRefRock:
14684 case wHammer:
14685 case wHookshot:
14686 case wHSHandle:
14687 case wHSChain:
14688 case wSSparkle:
14689 case wFSparkle:
14690 case wSmack:
14691 case wPhantom:
14692 case wCByrna:
14693 case wRefBeam:
14694 case wStomp:
14695 case lwMax:
14696 case wScript1:
14697 case wScript2:
14698 case wScript3:
14699 case wScript4:
14700 case wScript5:
14701 case wScript6:
14702 case wScript7:
14703 case wScript8:
14704 case wScript9:
14705 case wScript10:
14706 case wIce:
14707 //Cannot use any of these weapons yet.
14708 tempguy.wpnsprite = -1;
14709 break;
14710
14711 case wEnemyWeapons:
14712 960 case ewFireball: tempguy.wpnsprite = 17; break;
14713
14714 211 case ewArrow: tempguy.wpnsprite = 19; break;
14715 237 case ewBrang: tempguy.wpnsprite = 4; break;
14716 711 case ewSword: tempguy.wpnsprite = 20; break;
14717 347 case ewRock: tempguy.wpnsprite = 18; break;
14718 667 case ewMagic: tempguy.wpnsprite = 21; break;
14719 55 case ewBomb: tempguy.wpnsprite = 78; break;
14720 13 case ewSBomb: tempguy.wpnsprite = 79; break;
14721 97 case ewLitBomb: tempguy.wpnsprite = 76; break;
14722 13 case ewLitSBomb: tempguy.wpnsprite = 77; break;
14723 256 case ewFireTrail: tempguy.wpnsprite = 80; break;
14724 552 case ewFlame: tempguy.wpnsprite = 35; break;
14725 75 case ewWind: tempguy.wpnsprite = 36; break;
14726 55 case ewFlame2: tempguy.wpnsprite = 81; break;
14727 case ewFlame2Trail: tempguy.wpnsprite = 82; break;
14728 case ewIce: tempguy.wpnsprite = 83; break;
14729 610 case ewFireball2: tempguy.wpnsprite = 17; break; //fireball (rising)
14730
14731
14732 default: break; //No assign.
14733 }
14734 28160 }
14735 28160 }
14736
14737 //default weapon fire sound (quest version < 2.54)
14738 //port over old defaults and zero new data. -Z
14739
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 28160 times.
29696 if(guyversion < 34)
14740 {
14741
2/2
✓ Branch 0 taken 901120 times.
✓ Branch 1 taken 28160 times.
929280 for ( int32_t q = 0; q < 32; q++ )
14742 {
14743 901120 tempguy.movement[q] = 0;
14744 901120 tempguy.new_weapon[q] = 0;
14745
14746 901120 }
14747
14748 //NPC Script attributes.
14749 28160 tempguy.script = 0; //No scripted enemies existed. -Z
14750
2/2
✓ Branch 0 taken 225280 times.
✓ Branch 1 taken 28160 times.
253440 for ( int32_t q = 0; q < 8; q++ ) tempguy.initD[q] = 0; //Script Data
14751
2/2
✓ Branch 0 taken 56320 times.
✓ Branch 1 taken 28160 times.
84480 for ( int32_t q = 0; q < 2; q++ ) tempguy.initA[q] = 0; //Script Data
14752
14753 28160 tempguy.misc16 = 0;
14754 28160 tempguy.misc17 = 0;
14755 28160 tempguy.misc18 = 0;
14756 28160 tempguy.misc19 = 0;
14757 28160 tempguy.misc20 = 0;
14758 28160 tempguy.misc21 = 0;
14759 28160 tempguy.misc22 = 0;
14760 28160 tempguy.misc23 = 0;
14761 28160 tempguy.misc24 = 0;
14762 28160 tempguy.misc25 = 0;
14763 28160 tempguy.misc26 = 0;
14764 28160 tempguy.misc27 = 0;
14765 28160 tempguy.misc28 = 0;
14766 28160 tempguy.misc29 = 0;
14767 28160 tempguy.misc30 = 0;
14768 28160 tempguy.misc31 = 0;
14769 28160 tempguy.misc32 = 0;
14770
14771 //old default sounds
14772
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28160 times.
28160 if ( tempguy.firesfx <= 0 )
14773 {
14774
16/20
✗ Branch 0 not taken.
✓ Branch 1 taken 960 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 23301 times.
✓ Branch 4 taken 211 times.
✓ Branch 5 taken 237 times.
✓ Branch 6 taken 711 times.
✓ Branch 7 taken 347 times.
✓ Branch 8 taken 667 times.
✓ Branch 9 taken 55 times.
✓ Branch 10 taken 13 times.
✓ Branch 11 taken 97 times.
✓ Branch 12 taken 13 times.
✓ Branch 13 taken 256 times.
✓ Branch 14 taken 552 times.
✓ Branch 15 taken 75 times.
✓ Branch 16 taken 55 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 610 times.
28160 switch(tempguy.weapon)
14775 {
14776 case wNone:
14777 23301 tempguy.firesfx = 0; break;
14778
14779 case wSword:
14780 case wBeam:
14781 case wBrang:
14782 case wBomb:
14783 case wSBomb:
14784 case wLitBomb:
14785 case wLitSBomb:
14786 case wArrow:
14787 case wFire:
14788 case wWhistle:
14789 case wBait:
14790 case wWand:
14791 case wMagic:
14792 case wCatching:
14793 case wWind:
14794 case wRefMagic:
14795 case wRefFireball:
14796 case wRefRock:
14797 case wHammer:
14798 case wHookshot:
14799 case wHSHandle:
14800 case wHSChain:
14801 case wSSparkle:
14802 case wFSparkle:
14803 case wSmack:
14804 case wPhantom:
14805 case wCByrna:
14806 case wRefBeam:
14807 case wStomp:
14808 case lwMax:
14809 case wScript1:
14810 case wScript2:
14811 case wScript3:
14812 case wScript4:
14813 case wScript5:
14814 case wScript6:
14815 case wScript7:
14816 case wScript8:
14817 case wScript9:
14818 case wScript10:
14819 case wIce:
14820 //Cannot use any of these weapons yet.
14821 tempguy.firesfx = -1;
14822 break;
14823
14824 case wEnemyWeapons:
14825 960 case ewFireball: tempguy.firesfx = 40; break;
14826
14827 211 case ewArrow: tempguy.firesfx = 1; break; //Ghost.zh has 0?
14828 237 case ewBrang: tempguy.firesfx = 4; break; //Ghost.zh has 0?
14829 711 case ewSword: tempguy.firesfx = 20; break; //Ghost.zh has 0?
14830 347 case ewRock: tempguy.firesfx = 51; break;
14831 667 case ewMagic: tempguy.firesfx = 32; break;
14832 55 case ewBomb: tempguy.firesfx = 3; break; //Ghost.zh has 0?
14833 13 case ewSBomb: tempguy.firesfx = 3; break; //Ghost.zh has 0?
14834 97 case ewLitBomb: tempguy.firesfx = 21; break; //Ghost.zh has 0?
14835 13 case ewLitSBomb: tempguy.firesfx = 21; break; //Ghost.zh has 0?
14836 256 case ewFireTrail: tempguy.firesfx = 13; break;
14837 552 case ewFlame: tempguy.firesfx = 13; break;
14838 75 case ewWind: tempguy.firesfx = 32; break;
14839 55 case ewFlame2: tempguy.firesfx = 13; break;
14840 case ewFlame2Trail: tempguy.firesfx = 13; break;
14841 case ewIce: tempguy.firesfx = 44; break;
14842 610 case ewFireball2: tempguy.firesfx = 40; break; //fireball (rising)
14843
14844 //what about special attacks (e.g. summoning == 56)
14845 default: break; //No assign.
14846 }
14847 28160 }
14848 28160 }
14849
14850 //Port hardcoded hit sound to the enemy hitsfx defaults for older quests.
14851
4/6
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 28160 times.
✓ Branch 2 taken 1536 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1536 times.
29696 if(Header->zelda_version <= 0x250 || ( Header->zelda_version > 0x250 && guyversion < 35 ))
14852 {
14853
2/2
✓ Branch 0 taken 2345 times.
✓ Branch 1 taken 25815 times.
28160 if ( tempguy.hitsfx == 0 ) tempguy.hitsfx = 11;
14854 28160 }
14855 //Keese and bat halt rates.
14856
3/4
✓ Branch 0 taken 28160 times.
✓ Branch 1 taken 1536 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 28160 times.
29696 if ( guyversion < 42 && guy_cversion < 4 )
14857 {
14858
14859
2/2
✓ Branch 0 taken 27760 times.
✓ Branch 1 taken 400 times.
28160 if ( tempguy.family == eeKEESE )
14860 {
14861
14862
2/2
✓ Branch 0 taken 167 times.
✓ Branch 1 taken 233 times.
400 if ( !tempguy.misc1 )
14863 {
14864 233 tempguy.misc16 = 120;
14865 233 tempguy.misc17 = 16;
14866
14867 233 }
14868 400 }
14869
2/2
✓ Branch 0 taken 28040 times.
✓ Branch 1 taken 120 times.
28160 if ( tempguy.family == eePEAHAT )
14870 {
14871 120 tempguy.misc16 = 80;
14872 120 tempguy.misc17 = 16;
14873 120 }
14874
2/2
✓ Branch 0 taken 28105 times.
✓ Branch 1 taken 55 times.
28160 if ( tempguy.family == eeGHINI )
14875 {
14876 55 tempguy.misc16 = 120;
14877 55 tempguy.misc17 = 10;
14878 55 }
14879
14880
14881 28160 }
14882
14883
14884 //miscellaneous other corrections
14885 //fix the mirror wizzrobe -DD
14886
1/2
✓ Branch 0 taken 29696 times.
✗ Branch 1 not taken.
29696 if(guyversion < 7)
14887 {
14888 if(i == eMWIZ)
14889 {
14890 tempguy.misc2 = 0;
14891 tempguy.misc4 = 1;
14892 }
14893 }
14894
14895
1/2
✓ Branch 0 taken 29696 times.
✗ Branch 1 not taken.
29696 if(guyversion < 8)
14896 {
14897 if(i == eGLEEOK1 || i == eGLEEOK2 || i == eGLEEOK3 || i == eGLEEOK4 || i == eGLEEOK1F || i == eGLEEOK2F || i == eGLEEOK3F || i == eGLEEOK4F)
14898 {
14899 // Some of these are deliberately different to NewDefault/defdata.cpp, by the way. -L
14900 tempguy.misc5 = 4; //neck length in segments
14901 tempguy.misc6 = 8; //neck offset from first body tile
14902 tempguy.misc7 = 40; //offset for each subsequent neck tile from the first neck tile
14903 tempguy.misc8 = 168; //head offset from first body tile
14904 tempguy.misc9 = 228; //flying head offset from first body tile
14905
14906 if(i == eGLEEOK1F || i == eGLEEOK2F || i == eGLEEOK3F || i == eGLEEOK4F)
14907 {
14908 tempguy.misc6 += 10; //neck offset from first body tile
14909 tempguy.misc8 -= 12; //head offset from first body tile
14910 }
14911 }
14912 }
14913
14914
1/2
✓ Branch 0 taken 29696 times.
✗ Branch 1 not taken.
29696 if(guyversion < 10) // December 2007 - Dodongo CSet fix
14915 {
14916 if(get_bit(deprecated_rules,46) && tempguy.family==eeDONGO && tempguy.misc1==0)
14917 tempguy.bosspal = spDIG;
14918 }
14919
14920
1/2
✓ Branch 0 taken 29696 times.
✗ Branch 1 not taken.
29696 if(guyversion < 11) // December 2007 - Spinning Tile fix
14921 {
14922 if(tempguy.family==eeSPINTILE)
14923 {
14924 tempguy.flags |= guy_superman;
14925 tempguy.item_set = 0; // Don't drop items
14926 tempguy.step = 300;
14927 }
14928 }
14929
14930
1/2
✓ Branch 0 taken 29696 times.
✗ Branch 1 not taken.
29696 if(guyversion < 12) // October 2008 - Flashing Bubble, Rope 2, and Ghini 2 fix
14931 {
14932 if(get_bit(deprecated_rules, qr_NOROPE2FLASH_DEP))
14933 {
14934 if(tempguy.family==eeROPE)
14935 {
14936 tempguy.flags2 &= ~guy_flashing;
14937 }
14938 }
14939
14940 if(get_bit(deprecated_rules, qr_NOBUBBLEFLASH_DEP))
14941 {
14942 if(tempguy.family==eeBUBBLE)
14943 {
14944 tempguy.flags2 &= ~guy_flashing;
14945 }
14946 }
14947
14948 if((tempguy.family==eeGHINI)&&(tempguy.misc1))
14949 {
14950 if(get_bit(deprecated_rules, qr_GHINI2BLINK_DEP))
14951 {
14952 tempguy.flags2 |= guy_blinking;
14953 }
14954
14955 if(get_bit(deprecated_rules, qr_PHANTOMGHINI2_DEP))
14956 {
14957 tempguy.flags2 |= guy_transparent;
14958 }
14959 }
14960 }
14961
14962
1/2
✓ Branch 0 taken 29696 times.
✗ Branch 1 not taken.
29696 if(guyversion < 15) // July 2009 - Guy Fire and Fairy fix
14963 {
14964 if(i==gFIRE)
14965 {
14966 tempguy.e_anim = aFLIP;
14967 tempguy.e_frate = 24;
14968 }
14969
14970 if(i==gFAIRY)
14971 {
14972 tempguy.e_anim = a2FRM;
14973 tempguy.e_frate = 16;
14974 }
14975 }
14976
14977
1/2
✓ Branch 0 taken 29696 times.
✗ Branch 1 not taken.
29696 if(guyversion < 16) // November 2009 - Super Enemy Editor part 1
14978 {
14979 if(i==0) Z_message("Updating guys to version 16...\n");
14980
14981 update_guy_1(&tempguy);
14982
14983 if(i==eMPOLSV)
14984 {
14985 tempguy.defense[edefARROW] = edCHINK;
14986 tempguy.defense[edefMAGIC] = ed1HKO;
14987 tempguy.defense[edefREFMAGIC] = ed1HKO;
14988 }
14989 }
14990
14991
1/2
✓ Branch 0 taken 29696 times.
✗ Branch 1 not taken.
29696 if(guyversion < 17) // December 2009
14992 {
14993 if(tempguy.family==eePROJECTILE)
14994 {
14995 tempguy.misc1 = 0;
14996 }
14997 }
14998
14999
1/2
✓ Branch 0 taken 29696 times.
✗ Branch 1 not taken.
29696 if(guyversion < 18) // January 2010
15000 {
15001 bool boss = (tempguy.family == eeAQUA || tempguy.family==eeDONGO || tempguy.family == eeMANHAN || tempguy.family == eeGHOMA || tempguy.family==eeDIG
15002 || tempguy.family == eeGLEEOK || tempguy.family==eePATRA || tempguy.family == eeGANON || tempguy.family==eeMOLD);
15003
15004 tempguy.hitsfx = (boss && tempguy.family != eeMOLD && tempguy.family != eeDONGO && tempguy.family != eeDIG) ? WAV_GASP : 0;
15005 tempguy.deadsfx = (boss && (tempguy.family != eeDIG || tempguy.misc10 == 0)) ? WAV_GASP : WAV_EDEAD;
15006
15007 if(tempguy.family == eeAQUA)
15008 for(int32_t j=0; j<edefLAST; j++) tempguy.defense[j] = default_guys[eRAQUAM].defense[j];
15009 else if(tempguy.family == eeMANHAN)
15010 for(int32_t j=0; j<edefLAST; j++) tempguy.defense[j] = default_guys[eMANHAN].defense[j];
15011 else if(tempguy.family==eePATRA)
15012 for(int32_t j=0; j<edefLAST; j++) tempguy.defense[j] = default_guys[eGLEEOK1].defense[j];
15013 else if(tempguy.family==eeGHOMA)
15014 {
15015 for(int32_t j=0; j<edefLAST; j++)
15016 tempguy.defense[j] = default_guys[eGOHMA1].defense[j];
15017
15018 tempguy.defense[edefARROW] = ((tempguy.misc1==3) ? edCHINKL8 : (tempguy.misc1==2) ? edCHINKL4 : 0);
15019
15020 if(tempguy.misc1==3 && !tempguy.weapon) tempguy.weapon = ewFlame;
15021
15022 tempguy.misc1--;
15023 }
15024 else if(tempguy.family == eeGLEEOK)
15025 {
15026 for(int32_t j=0; j<edefLAST; j++)
15027 tempguy.defense[j] = default_guys[eGLEEOK1].defense[j];
15028
15029 if(tempguy.misc3==1 && !tempguy.weapon) tempguy.weapon = ewFlame;
15030 }
15031 else if(tempguy.family == eeARMOS)
15032 {
15033 tempguy.family=eeWALK;
15034 tempguy.hrate = 0;
15035 tempguy.misc10 = tempguy.misc1;
15036 tempguy.misc1 = tempguy.misc2 = tempguy.misc3 = tempguy.misc4 = tempguy.misc5 = tempguy.misc6 = tempguy.misc7 = tempguy.misc8 = 0;
15037 tempguy.misc9 = e9tARMOS;
15038 }
15039 else if(tempguy.family == eeGHINI && !tempguy.misc1)
15040 {
15041 tempguy.family=eeWALK;
15042 tempguy.hrate = 0;
15043 tempguy.misc1 = tempguy.misc2 = tempguy.misc3 = tempguy.misc4 = tempguy.misc5 = tempguy.misc6 =
15044 tempguy.misc7 = tempguy.misc8 = tempguy.misc9 = tempguy.misc10 = 0;
15045 }
15046
15047 // Spawn animation flags
15048 if(tempguy.family == eeWALK && (tempguy.flags2&cmbflag_armos || tempguy.flags2&cmbflag_ghini))
15049 tempguy.flags |= guy_fadeflicker;
15050 else
15051 tempguy.flags &= 0x0F00000F; // Get rid of the unused flags!
15052 }
15053
15054
1/2
✓ Branch 0 taken 29696 times.
✗ Branch 1 not taken.
29696 if(guyversion < 20) // April 2010
15055 {
15056 if(tempguy.family == eeTRAP)
15057 {
15058 tempguy.misc2 = tempguy.misc10;
15059
15060 if(tempguy.misc10>=1)
15061 {
15062 tempguy.misc1++;
15063 }
15064
15065 tempguy.misc10 = 0;
15066 }
15067
15068 // Bomb Blast fix
15069 if(tempguy.weapon==ewBomb && tempguy.family!=eeROPE && (tempguy.family!=eeWALK || tempguy.misc2 != e2tBOMBCHU))
15070 tempguy.weapon = ewLitBomb;
15071 else if(tempguy.weapon==ewSBomb && tempguy.family!=eeROPE && (tempguy.family!=eeWALK || tempguy.misc2 != e2tBOMBCHU))
15072 tempguy.weapon = ewLitSBomb;
15073 }
15074
15075
1/2
✓ Branch 0 taken 29696 times.
✗ Branch 1 not taken.
29696 if(guyversion < 21) // September 2011
15076 {
15077 if(tempguy.family == eeKEESE || tempguy.family == eeKEESETRIB)
15078 {
15079 if(tempguy.family == eeKEESETRIB)
15080 {
15081 tempguy.family = eeKEESE;
15082 tempguy.misc2 = e2tKEESETRIB;
15083 tempguy.misc1 = 0;
15084 }
15085
15086 tempguy.rate = 2;
15087 tempguy.hrate = 8;
15088 tempguy.homing = 0;
15089 tempguy.step= (tempguy.family == eeKEESE && tempguy.misc1 ? 100:62);
15090 }
15091 else if(tempguy.family == eePEAHAT || tempguy.family==eePATRA)
15092 {
15093 if(tempguy.family == eePEAHAT)
15094 {
15095 tempguy.rate = 4;
15096 tempguy.step = 62;
15097 }
15098 else
15099 tempguy.step = 25;
15100
15101 tempguy.hrate = 8;
15102 tempguy.homing = 0;
15103 }
15104 else if(tempguy.family == eeDIG || tempguy.family == eeMANHAN)
15105 {
15106 if(tempguy.family == eeMANHAN)
15107 tempguy.step=50;
15108
15109 tempguy.hrate = 16;
15110 tempguy.homing = 0;
15111 }
15112 else if(tempguy.family == eeGLEEOK)
15113 {
15114 tempguy.rate = 2;
15115 tempguy.homing = 0;
15116 tempguy.hrate = 9;
15117 tempguy.step=89;
15118 }
15119 else if(tempguy.family == eeGHINI)
15120 {
15121 tempguy.rate = 4;
15122 tempguy.hrate = 12;
15123 tempguy.step=62;
15124 tempguy.homing = 0;
15125 }
15126
15127 // Bigdig random rate fix
15128 if(tempguy.family==eeDIG && tempguy.misc10==1)
15129 {
15130 tempguy.rate = 2;
15131 }
15132 }
15133
15134
1/2
✓ Branch 0 taken 29696 times.
✗ Branch 1 not taken.
29696 if(guyversion < 24) // November 2012
15135 {
15136 if(tempguy.family==eeLANM)
15137 tempguy.misc3 = 1;
15138 else if(tempguy.family==eeMOLD)
15139 tempguy.misc2 = 0;
15140 }
15141
15142
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 28160 times.
29696 if(guyversion < 33) //Whistle defence did not exist before this version of 2.54. -Z
15143 {
15144
2/2
✓ Branch 0 taken 508 times.
✓ Branch 1 taken 27652 times.
28160 if(tempguy.family!=eeDIG)
15145 {
15146 27652 tempguy.defense[edefWhistle] = edIGNORE; //Might need to be ignore, universally.
15147 27652 }
15148
15149 28160 }
15150 // does not seem to solve the issue!
15151
1/2
✓ Branch 0 taken 29696 times.
✗ Branch 1 not taken.
29696 if ( Header->zelda_version <= 0x210 )
15152 {
15153 al_trace("Detected version %d for dodongo patch.\n",Header->zelda_version);
15154 if ( tempguy.family == eeDONGO )
15155 {
15156 tempguy.deadsfx = 15; //In 2.10 and earlier, Dodongos used this as their death sound.
15157 }
15158 }
15159
15160
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 28160 times.
29696 if(guyversion >= 42)
15161 {
15162
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(guyversion >= 47)
15163 {
15164
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(!p_igetl(&(tempguy.moveflags),f,keepdata))
15165 {
15166 return qe_invalid;
15167 }
15168 1536 }
15169 else
15170 {
15171 byte fl;
15172 if(!p_getc(&fl,f,keepdata))
15173 {
15174 return qe_invalid;
15175 }
15176 tempguy.moveflags = fl;
15177 }
15178 1536 }
15179 else
15180 {
15181
7/8
✓ Branch 0 taken 50 times.
✓ Branch 1 taken 22126 times.
✓ Branch 2 taken 902 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 373 times.
✓ Branch 5 taken 201 times.
✓ Branch 6 taken 176 times.
✓ Branch 7 taken 4332 times.
28160 switch(tempguy.family)
15182 {
15183 //No gravity; floats over pits
15184 case eeTEK: case eePEAHAT: case eeROCK: case eeTRAP:
15185 case eePROJECTILE: case eeSPINTILE: case eeKEESE: case eeFIRE:
15186 //Special (bosses, etc)
15187 case eeFAIRY: case eeGUY: case eeNONE: case eeZORA:
15188 case eeAQUA: case eeDIG: case eeGHOMA: case eeGANON:
15189 case eePATRA: case eeGLEEOK: case eeMOLD: case eeMANHAN:
15190 22126 tempguy.moveflags = FLAG_CAN_PITWALK;
15191 22126 break;
15192 //No gravity, but falls in pits
15193 case eeLEV:
15194 373 tempguy.moveflags = FLAG_CAN_PITFALL;
15195 373 break;
15196 //Bosses that respect pits
15197 case eeDONGO:
15198 201 tempguy.moveflags = FLAG_OBEYS_GRAV;
15199 201 break;
15200 case eeLANM:
15201 176 tempguy.moveflags = 0;
15202 176 break;
15203 //Gravity, floats over pits
15204 case eeWIZZ: case eeWALLM: case eeGHINI:
15205 902 tempguy.moveflags = FLAG_OBEYS_GRAV | FLAG_CAN_PITWALK;
15206 902 break;
15207 //Gravity and falls in pits
15208 case eeWALK:
15209
4/4
✓ Branch 0 taken 4091 times.
✓ Branch 1 taken 241 times.
✓ Branch 2 taken 208 times.
✓ Branch 3 taken 3883 times.
4332 if (tempguy.misc9==e9tPOLSVOICE||tempguy.misc9==e9tVIRE)
15210 449 break;
15211 [[fallthrough]];
15212 case eeOTHER:
15213 case eeSCRIPT01: case eeSCRIPT02: case eeSCRIPT03: case eeSCRIPT04: case eeSCRIPT05:
15214 case eeSCRIPT06: case eeSCRIPT07: case eeSCRIPT08: case eeSCRIPT09: case eeSCRIPT10:
15215 case eeSCRIPT11: case eeSCRIPT12: case eeSCRIPT13: case eeSCRIPT14: case eeSCRIPT15:
15216 case eeSCRIPT16: case eeSCRIPT17: case eeSCRIPT18: case eeSCRIPT19: case eeSCRIPT20:
15217 case eeFFRIENDLY01: case eeFFRIENDLY02: case eeFFRIENDLY03: case eeFFRIENDLY04: case eeFFRIENDLY05:
15218 case eeFFRIENDLY06: case eeFFRIENDLY07: case eeFFRIENDLY08: case eeFFRIENDLY09: case eeFFRIENDLY10:
15219 3933 tempguy.moveflags = FLAG_OBEYS_GRAV | FLAG_CAN_PITFALL;
15220 3933 }
15221 }
15222
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 28160 times.
29696 if(guyversion < 43)
15223 {
15224
2/2
✓ Branch 0 taken 23028 times.
✓ Branch 1 taken 5132 times.
28160 switch(tempguy.family)
15225 {
15226 //No gravity; floats over pits
15227 case eeTEK: case eePEAHAT: case eeROCK: case eeTRAP:
15228 case eePROJECTILE: case eeSPINTILE: case eeKEESE: case eeFIRE:
15229 //Special (bosses, etc)
15230 case eeFAIRY: case eeGUY: case eeNONE: case eeZORA:
15231 case eeAQUA: case eeDIG: case eeGHOMA: case eeGANON:
15232 case eePATRA: case eeGLEEOK: case eeMOLD: case eeMANHAN:
15233 case eeWIZZ: case eeWALLM: case eeGHINI:
15234 //Gravity, floats over pits
15235 23028 tempguy.moveflags |= FLAG_CAN_WATERWALK;
15236 23028 break;
15237 }
15238 28160 }
15239
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 28160 times.
29696 if (guyversion < 44)
15240 {
15241
2/2
✓ Branch 0 taken 27879 times.
✓ Branch 1 taken 281 times.
28160 if ( tempguy.family == eeGHOMA )
15242 {
15243 281 tempguy.flags |= guy_fadeinstant;
15244 281 }
15245 28160 }
15246
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 28160 times.
29696 if (guyversion > 44)
15247 {
15248
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(!p_getc(&(tempguy.spr_shadow),f,keepdata))
15249 {
15250 return qe_invalid;
15251 }
15252
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(!p_getc(&(tempguy.spr_death),f,keepdata))
15253 {
15254 return qe_invalid;
15255 }
15256
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(!p_getc(&(tempguy.spr_spawn),f,keepdata))
15257 {
15258 return qe_invalid;
15259 }
15260 1536 }
15261 else
15262 {
15263
2/2
✓ Branch 0 taken 28050 times.
✓ Branch 1 taken 110 times.
28160 tempguy.spr_shadow = (tempguy.family==eeROCK && tempguy.misc10==1) ? iwLargeShadow : iwShadow;
15264 28160 tempguy.spr_death = iwDeath;
15265 28160 tempguy.spr_spawn = iwSpawn;
15266 }
15267
15268
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 28160 times.
29696 if(guyversion < 46)
15269 {
15270
4/4
✓ Branch 0 taken 4332 times.
✓ Branch 1 taken 23828 times.
✓ Branch 2 taken 4091 times.
✓ Branch 3 taken 241 times.
28160 if(tempguy.family == eeWALK && tempguy.misc9 == e9tPOLSVOICE)
15271 {
15272 241 tempguy.moveflags |= FLAG_CAN_WATERWALK;
15273 241 }
15274 28160 }
15275
15276
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29696 times.
29696 if(keepdata)
15277 {
15278 29696 guysbuf[i] = tempguy;
15279 29696 }
15280 29696 }
15281 58 }
15282
15283 58 return 0;
15284 58 }
15285
15286 void update_guy_1(guydata *tempguy) // November 2009
15287 {
15288 bool doesntcount = false;
15289 tempguy->flags &= ~weak_arrow; // Formerly 'weak to arrow' which wasn't implemented
15290
15291 switch(tempguy->family)
15292 {
15293 case 1: //eeWALK
15294 switch(tempguy->misc10)
15295 {
15296 case 0: //Stalfos
15297 if(tempguy->misc1==1) // Fires four projectiles at once
15298 tempguy->misc1=4;
15299
15300 break;
15301
15302 case 1: //Darknut
15303 goto darknuts;
15304 break;
15305 }
15306
15307 tempguy->misc10 = 0;
15308 break;
15309
15310 case 2: //eeSHOOT
15311 tempguy->family = eeWALK;
15312
15313 switch(tempguy->misc10)
15314 {
15315 case 0: //Octorok
15316 if(tempguy->misc1==1||tempguy->misc1==2)
15317 {
15318 tempguy->misc1=e1tFIREOCTO;
15319 tempguy->misc2=e2tFIREOCTO;
15320 }
15321 else tempguy->misc1 = 0;
15322
15323 tempguy->misc6=tempguy->misc4;
15324 tempguy->misc4=tempguy->misc3;
15325 tempguy->misc3=0;
15326 break;
15327
15328 case 1: // Moblin
15329 tempguy->misc1 = 0;
15330 break;
15331
15332 case 2: //Lynel
15333 tempguy->misc6=tempguy->misc1+1;
15334 tempguy->misc1=0;
15335 break;
15336
15337 case 3: //Stalfos 2
15338 if(tempguy->misc1==1) // Fires four projectiles at once
15339 tempguy->misc1=e1t4SHOTS;
15340 else tempguy->misc1 = 0;
15341
15342 break;
15343
15344 case 4: //Darknut 5
15345 darknuts:
15346 tempguy->defense[edefFIRE] = edIGNORE;
15347 tempguy->defense[edefBRANG] = edSTUNORCHINK;
15348 tempguy->defense[edefHOOKSHOT] = 0;
15349 tempguy->defense[edefARROW] = tempguy->defense[edefBYRNA] = tempguy->defense[edefREFROCK] =
15350 tempguy->defense[edefMAGIC] = tempguy->defense[edefSTOMP] = edCHINK;
15351
15352 if(tempguy->misc1==1)
15353 tempguy->misc1=2;
15354 else if(tempguy->misc1==2)
15355 {
15356 tempguy->misc4=tempguy->misc3;
15357 tempguy->misc3=tempguy->misc2;
15358 tempguy->misc2=e2tSPLIT;
15359 tempguy->misc1 = 0;
15360 }
15361 else tempguy->misc1 = 0;
15362
15363 tempguy->flags |= inv_front;
15364
15365 if(get_bit(deprecated_rules,qr_BRKBLSHLDS_DEP))
15366 tempguy->flags |= guy_bkshield;
15367
15368 break;
15369 }
15370
15371 tempguy->misc10 = 0;
15372 break;
15373
15374 /*
15375 case 9: //eeARMOS
15376 tempguy->family = eeWALK;
15377 break;
15378 */
15379 case 11: //eeGEL
15380 case 33: //eeGELTRIB
15381 if(tempguy->family==33)
15382 {
15383 tempguy->misc4 = 1;
15384
15385 if(get_bit(deprecated_rules, qr_OLDTRIBBLES_DEP)) //Old Tribbles
15386 tempguy->misc3 = tempguy->misc2;
15387
15388 tempguy->misc2 = e2tTRIBBLE;
15389 }
15390 else
15391 {
15392 tempguy->misc4 = 0;
15393 tempguy->misc3 = 0;
15394 tempguy->misc2 = 0;
15395 }
15396
15397 tempguy->family = eeWALK;
15398
15399 if(tempguy->misc1)
15400 {
15401 tempguy->misc1=1;
15402 tempguy->weapon = ewFireTrail;
15403 }
15404
15405 break;
15406
15407 case 34: //eeZOLTRIB
15408 case 12: //eeZOL
15409 tempguy->misc4=tempguy->misc3;
15410 tempguy->misc3=tempguy->misc2;
15411 tempguy->family = eeWALK;
15412 tempguy->misc2=e2tSPLITHIT;
15413
15414 if(tempguy->misc1)
15415 {
15416 tempguy->misc1=1;
15417 tempguy->weapon = ewFireTrail;
15418 }
15419
15420 break;
15421
15422 case 13: //eeROPE
15423 tempguy->family = eeWALK;
15424 tempguy->misc9 = e9tROPE;
15425
15426 if(tempguy->misc1)
15427 {
15428 tempguy->misc4 = tempguy->misc3;
15429 tempguy->misc3 = tempguy->misc2;
15430 tempguy->misc2 = e2tBOMBCHU;
15431 }
15432
15433 tempguy->misc1 = 0;
15434 break;
15435
15436 case 14: //eeGORIYA
15437 tempguy->family = eeWALK;
15438
15439 if(tempguy->misc1!=2) tempguy->misc1 = 0;
15440
15441 break;
15442
15443 case 17: //eeBUBBLE
15444 tempguy->family = eeWALK;
15445 tempguy->misc8 = tempguy->misc2;
15446 tempguy->misc7 = tempguy->misc1 + 1;
15447 tempguy->misc1 = tempguy->misc2 = 0;
15448
15449 //fallthrogh
15450 case eeTRAP:
15451 case eeROCK:
15452 doesntcount = true;
15453 break;
15454
15455 case 35: //eeVIRETRIB
15456 case 18: //eeVIRE
15457 tempguy->family = eeWALK;
15458 tempguy->misc4=tempguy->misc3;
15459 tempguy->misc3=tempguy->misc2;
15460 tempguy->misc2=e2tSPLITHIT;
15461 tempguy->misc9=e9tVIRE;
15462 break;
15463
15464 case 19: //eeLIKE
15465 tempguy->family = eeWALK;
15466 tempguy->misc7 = e7tEATITEMS;
15467 tempguy->misc8=95;
15468 break;
15469
15470 case 20: //eePOLSV
15471 tempguy->defense[edefBRANG] = edSTUNORCHINK;
15472 tempguy->defense[edefBOMB] = tempguy->defense[edefSBOMB] = tempguy->defense[edefFIRE] = edIGNORE;
15473 tempguy->defense[edefMAGIC] = tempguy->defense[edefBYRNA] = edCHINK;
15474 tempguy->defense[edefARROW] = ed1HKO;
15475 tempguy->defense[edefHOOKSHOT] = edSTUNONLY;
15476 tempguy->family = eeWALK;
15477 tempguy->misc9 = e9tPOLSVOICE;
15478 tempguy->rate = 4;
15479 tempguy->homing = 32;
15480 tempguy->hrate = 10;
15481 tempguy->grumble = 0;
15482 break;
15483
15484 case eeWIZZ:
15485 if(tempguy->misc4)
15486 {
15487 for(int32_t i=0; i < edefLAST; i++)
15488 tempguy->defense[i] = (i != edefREFBEAM && i != edefREFMAGIC && i != edefQUAKE) ? edIGNORE : 0;
15489 }
15490 else
15491 {
15492 tempguy->defense[edefBRANG] = edSTUNORCHINK;
15493 tempguy->defense[edefMAGIC] = edCHINK;
15494 tempguy->defense[edefHOOKSHOT] = edSTUNONLY;
15495 tempguy->defense[edefARROW] = tempguy->defense[edefFIRE] =
15496 tempguy->defense[edefWAND] = tempguy->defense[edefBYRNA] = edIGNORE;
15497 }
15498
15499 break;
15500
15501 case eePEAHAT:
15502 tempguy->flags &= ~(guy_superman|guy_sbombonly);
15503
15504 if(!(tempguy->flags & guy_bhit))
15505 tempguy->defense[edefBRANG] = edSTUNONLY;
15506
15507 break;
15508
15509 case eeLEV:
15510 tempguy->defense[edefSTOMP] = edCHINK;
15511 break;
15512 }
15513
15514 // Old flags
15515 if(tempguy->flags & guy_superman)
15516 {
15517 for(int32_t i = 0; i < edefLAST; i++)
15518 if(!(i==edefSBOMB && (tempguy->flags & guy_sbombonly)))
15519 tempguy->defense[i] = (i==edefBRANG && tempguy->defense[i] != edIGNORE
15520 && tempguy->family != eeROCK && tempguy->family != eeTRAP
15521 && tempguy->family != eePROJECTILE) ? edSTUNORIGNORE : edIGNORE;
15522 }
15523
15524 tempguy->flags &= ~(guy_superman|guy_sbombonly);
15525
15526 if(doesntcount)
15527 tempguy->flags |= (guy_doesntcount);
15528 }
15529
15530
15531 97240 int32_t readmapscreen_old(PACKFILE *f, zquestheader *Header, mapscr *temp_mapscr, zcmap *temp_map, word version)
15532 {
15533 byte tempbyte, padding;
15534 int32_t extras, secretcombos;
15535 //al_trace("readmapscreen Header->zelda_version: %x\n",Header->zelda_version);
15536
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 97240 times.
97240 if(!p_getc(&(temp_mapscr->valid),f,true))
15537 {
15538 return qe_invalid;
15539 }
15540
15541
15542
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 97240 times.
97240 if(!p_getc(&(temp_mapscr->guy),f,true))
15543 {
15544 return qe_invalid;
15545 }
15546
15547
2/6
✓ Branch 0 taken 97240 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 97240 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
97240 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<146)))
15548 {
15549 if(!p_getc(&tempbyte,f,true))
15550 {
15551 return qe_invalid;
15552 }
15553
15554 temp_mapscr->str=tempbyte;
15555 }
15556 else
15557 {
15558
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 97240 times.
97240 if(!p_igetw(&(temp_mapscr->str),f,true))
15559 {
15560 return qe_invalid;
15561 }
15562 }
15563
15564
1/2
✓ Branch 0 taken 97240 times.
✗ Branch 1 not taken.
97240 if(!p_getc(&(temp_mapscr->room),f,true))
15565 {
15566 return qe_invalid;
15567 }
15568
15569
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 97240 times.
97240 if(!p_getc(&(temp_mapscr->item),f,true))
15570 {
15571 return qe_invalid;
15572 }
15573
15574
2/6
✓ Branch 0 taken 97240 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 97240 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
97240 if(Header->zelda_version < 0x211 || (Header->zelda_version == 0x211 && Header->build < 14))
15575 {
15576 temp_mapscr->hasitem = (temp_mapscr->item != 0) ? 1 : 0;
15577 }
15578 else
15579 {
15580
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 97240 times.
97240 if(!p_getc(&(temp_mapscr->hasitem),f,true))
15581 return qe_invalid;
15582 }
15583
15584
1/4
✓ Branch 0 taken 97240 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
97240 if((Header->zelda_version < 0x192)||
15585
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 97240 times.
97240 ((Header->zelda_version == 0x192)&&(Header->build<154)))
15586 {
15587 if(!p_getc(&tempbyte,f,true))
15588 {
15589 return qe_invalid;
15590 }
15591 }
15592
15593
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 97240 times.
97240 if(!p_getc(&(temp_mapscr->tilewarptype[0]),f,true))
15594 {
15595 return qe_invalid;
15596 }
15597
15598
1/2
✓ Branch 0 taken 97240 times.
✗ Branch 1 not taken.
97240 if(Header->zelda_version < 0x193)
15599 {
15600 if(!p_getc(&tempbyte,f,true))
15601 {
15602 return qe_invalid;
15603 }
15604 }
15605
15606
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 97240 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
97240 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15607 {
15608
2/2
✓ Branch 0 taken 291720 times.
✓ Branch 1 taken 97240 times.
388960 for(int32_t i=1; i<4; i++)
15609 {
15610
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 291720 times.
291720 if(!p_getc(&(temp_mapscr->tilewarptype[i]),f,true))
15611 {
15612 return qe_invalid;
15613 }
15614 291720 }
15615 97240 }
15616 else
15617 {
15618 temp_mapscr->tilewarptype[1]=0;
15619 temp_mapscr->tilewarptype[2]=0;
15620 temp_mapscr->tilewarptype[3]=0;
15621 }
15622
15623
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 97240 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
97240 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>153)))
15624 {
15625
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 97240 times.
97240 if(!p_igetw(&(temp_mapscr->door_combo_set),f,true))
15626 {
15627 return qe_invalid;
15628 }
15629 97240 }
15630
15631
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 97240 times.
97240 if(!p_getc(&(temp_mapscr->warpreturnx[0]),f,true))
15632 {
15633 return qe_invalid;
15634 }
15635
15636 97240 temp_mapscr->warpreturnx[1]=0;
15637 97240 temp_mapscr->warpreturnx[2]=0;
15638 97240 temp_mapscr->warpreturnx[3]=0;
15639
15640
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 97240 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
97240 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15641 {
15642
2/2
✓ Branch 0 taken 291720 times.
✓ Branch 1 taken 97240 times.
388960 for(int32_t i=1; i<4; i++)
15643 {
15644
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 291720 times.
291720 if(!p_getc(&(temp_mapscr->warpreturnx[i]),f,true))
15645 {
15646 return qe_invalid;
15647 }
15648 291720 }
15649 97240 }
15650
15651
1/2
✓ Branch 0 taken 97240 times.
✗ Branch 1 not taken.
97240 if(!p_getc(&(temp_mapscr->warpreturny[0]),f,true))
15652 {
15653 return qe_invalid;
15654 }
15655
15656 97240 temp_mapscr->warpreturny[1]=0;
15657 97240 temp_mapscr->warpreturny[2]=0;
15658 97240 temp_mapscr->warpreturny[3]=0;
15659
15660
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 97240 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
97240 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15661 {
15662
2/2
✓ Branch 0 taken 291720 times.
✓ Branch 1 taken 97240 times.
388960 for(int32_t i=1; i<4; i++)
15663 {
15664
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 291720 times.
291720 if(!p_getc(&(temp_mapscr->warpreturny[i]),f,true))
15665 {
15666 return qe_invalid;
15667 }
15668 291720 }
15669
15670
1/2
✓ Branch 0 taken 97240 times.
✗ Branch 1 not taken.
97240 if(version>=18)
15671 {
15672
1/2
✓ Branch 0 taken 97240 times.
✗ Branch 1 not taken.
97240 if(!p_igetw(&temp_mapscr->warpreturnc,f,true))
15673 {
15674 return qe_invalid;
15675 }
15676 97240 }
15677 else
15678 {
15679 byte temp;
15680
15681 if(!p_getc(&temp,f,true))
15682 {
15683 return qe_invalid;
15684 }
15685
15686 temp_mapscr->warpreturnc=temp<<8|temp;
15687 }
15688 97240 }
15689
15690
1/2
✓ Branch 0 taken 97240 times.
✗ Branch 1 not taken.
97240 if(!p_getc(&(temp_mapscr->stairx),f,true))
15691
15692 {
15693 return qe_invalid;
15694 }
15695
15696
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 97240 times.
97240 if(!p_getc(&(temp_mapscr->stairy),f,true))
15697 {
15698 return qe_invalid;
15699 }
15700
15701
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 97240 times.
97240 if(!p_getc(&(temp_mapscr->itemx),f,true))
15702 {
15703 return qe_invalid;
15704 }
15705
15706
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 97240 times.
97240 if(!p_getc(&(temp_mapscr->itemy),f,true))
15707 {
15708 return qe_invalid;
15709 }
15710
15711
1/2
✓ Branch 0 taken 97240 times.
✗ Branch 1 not taken.
97240 if(version > 15) // February 2009
15712 {
15713
1/2
✓ Branch 0 taken 97240 times.
✗ Branch 1 not taken.
97240 if(!p_igetw(&(temp_mapscr->color),f,true))
15714 {
15715 return qe_invalid;
15716 }
15717 97240 }
15718 else
15719 {
15720 if(!p_getc(& tempbyte,f,true))
15721 {
15722 return qe_invalid;
15723 }
15724
15725 temp_mapscr->color = (word) tempbyte;
15726 }
15727
15728
1/2
✓ Branch 0 taken 97240 times.
✗ Branch 1 not taken.
97240 if(!p_getc(&(temp_mapscr->enemyflags),f,true))
15729 {
15730 return qe_invalid;
15731 }
15732
15733
2/2
✓ Branch 0 taken 388960 times.
✓ Branch 1 taken 97240 times.
486200 for(int32_t k=0; k<4; k++)
15734 {
15735
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 388960 times.
388960 if(!p_getc(&(temp_mapscr->door[k]),f,true))
15736 {
15737 return qe_invalid;
15738
15739 }
15740 388960 }
15741
15742
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 97240 times.
97240 if(version <= 11)
15743 {
15744 if(!p_getc(&(tempbyte),f,true))
15745 {
15746 return qe_invalid;
15747 }
15748
15749 temp_mapscr->tilewarpdmap[0]=(word)tempbyte;
15750
15751 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15752 {
15753 for(int32_t i=1; i<4; i++)
15754 {
15755 if(!p_getc(&(tempbyte),f,true))
15756 {
15757 return qe_invalid;
15758 }
15759
15760 temp_mapscr->tilewarpdmap[i]=(word)tempbyte;
15761 }
15762 }
15763 else
15764 {
15765 temp_mapscr->tilewarpdmap[1]=0;
15766 temp_mapscr->tilewarpdmap[2]=0;
15767 temp_mapscr->tilewarpdmap[3]=0;
15768 }
15769 }
15770 else
15771 {
15772
2/2
✓ Branch 0 taken 388960 times.
✓ Branch 1 taken 97240 times.
486200 for(int32_t i=0; i<4; i++)
15773 {
15774
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 388960 times.
388960 if(!p_igetw(&(temp_mapscr->tilewarpdmap[i]),f,true))
15775 {
15776 return qe_invalid;
15777 }
15778 388960 }
15779 }
15780
15781
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 97240 times.
97240 if(!p_getc(&(temp_mapscr->tilewarpscr[0]),f,true))
15782 {
15783 return qe_invalid;
15784 }
15785
15786
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 97240 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
97240 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15787 {
15788
2/2
✓ Branch 0 taken 291720 times.
✓ Branch 1 taken 97240 times.
388960 for(int32_t i=1; i<4; i++)
15789 {
15790
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 291720 times.
291720 if(!p_getc(&(temp_mapscr->tilewarpscr[i]),f,true))
15791 {
15792 return qe_invalid;
15793 }
15794 291720 }
15795 97240 }
15796 else
15797 {
15798 temp_mapscr->tilewarpscr[1]=0;
15799 temp_mapscr->tilewarpscr[2]=0;
15800 temp_mapscr->tilewarpscr[3]=0;
15801 }
15802
15803
1/2
✓ Branch 0 taken 97240 times.
✗ Branch 1 not taken.
97240 if(version >= 15)
15804 {
15805
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 97240 times.
97240 if(!p_getc(&(temp_mapscr->tilewarpoverlayflags),f,true))
15806 {
15807 return qe_invalid;
15808 }
15809 97240 }
15810 else
15811 {
15812 temp_mapscr->tilewarpoverlayflags=0;
15813 }
15814
15815
1/2
✓ Branch 0 taken 97240 times.
✗ Branch 1 not taken.
97240 if(!p_getc(&(temp_mapscr->exitdir),f,true))
15816 {
15817 return qe_invalid;
15818 }
15819
15820
1/2
✓ Branch 0 taken 97240 times.
✗ Branch 1 not taken.
97240 if(Header->zelda_version < 0x193)
15821 {
15822 if(!p_getc(&tempbyte,f,true))
15823 {
15824 return qe_invalid;
15825 }
15826
15827 }
15828
15829
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 97240 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
97240 if((Header->zelda_version == 0x192)&&(Header->build>145)&&(Header->build<154))
15830 {
15831 if(!p_getc(&padding,f,true))
15832 {
15833 return qe_invalid;
15834 }
15835 }
15836
15837
2/2
✓ Branch 0 taken 972400 times.
✓ Branch 1 taken 97240 times.
1069640 for(int32_t k=0; k<10; k++)
15838 {
15839 /*
15840 if (!temp_mapscr->enemy[k])
15841 {
15842 continue;
15843 }
15844 */
15845
2/6
✓ Branch 0 taken 972400 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 972400 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
972400 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<10)))
15846 {
15847 if(!p_getc(&tempbyte,f,true))
15848 {
15849 return qe_invalid;
15850 }
15851
15852 temp_mapscr->enemy[k]=tempbyte;
15853 }
15854 else
15855 {
15856
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 972400 times.
972400 if(!p_igetw(&(temp_mapscr->enemy[k]),f,true))
15857 {
15858 return qe_invalid;
15859 }
15860 }
15861
15862
2/6
✓ Branch 0 taken 972400 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 972400 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
972400 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<108)))
15863 {
15864 //using enumerations here is dangerous
15865 //very easy to break old quests -DD
15866 if(temp_mapscr->enemy[k]>=57) //old eGOHMA1
15867 {
15868 temp_mapscr->enemy[k]+=5;
15869 }
15870 else if(temp_mapscr->enemy[k]>=52) //old eGLEEOK2
15871 {
15872 temp_mapscr->enemy[k]+=1;
15873 }
15874 }
15875
15876
1/2
✓ Branch 0 taken 972400 times.
✗ Branch 1 not taken.
972400 if(version < 9)
15877 {
15878 if(temp_mapscr->enemy[k]>0)
15879 {
15880 temp_mapscr->enemy[k]+=10;
15881 }
15882 }
15883 //don't read in any invalid data
15884
1/2
✓ Branch 0 taken 972400 times.
✗ Branch 1 not taken.
972400 if ( ((unsigned)temp_mapscr->enemy[k]) > MAXGUYS )
15885 {
15886 al_trace("Tried to read an invalid enemy ID (%d) for tmpscr->enemy[%d]. This has been cleared to 0.\n", temp_mapscr->enemy[k], k);
15887 temp_mapscr->enemy[k] = 0;
15888 }
15889 972400 }
15890
15891
1/2
✓ Branch 0 taken 97240 times.
✗ Branch 1 not taken.
97240 if(!p_getc(&(temp_mapscr->pattern),f,true))
15892 {
15893 return qe_invalid;
15894 }
15895
15896
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 97240 times.
97240 if(!p_getc(&(temp_mapscr->sidewarptype[0]),f,true))
15897 {
15898 return qe_invalid;
15899 }
15900
15901
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 97240 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
97240 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15902 {
15903
2/2
✓ Branch 0 taken 291720 times.
✓ Branch 1 taken 97240 times.
388960 for(int32_t i=1; i<4; i++)
15904 {
15905
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 291720 times.
291720 if(!p_getc(&(temp_mapscr->sidewarptype[i]),f,true))
15906 {
15907 return qe_invalid;
15908 }
15909 291720 }
15910 97240 }
15911 else
15912 {
15913 temp_mapscr->sidewarptype[1]=0;
15914 temp_mapscr->sidewarptype[2]=0;
15915 temp_mapscr->sidewarptype[3]=0;
15916 }
15917
15918
1/2
✓ Branch 0 taken 97240 times.
✗ Branch 1 not taken.
97240 if(version >= 15)
15919 {
15920
1/2
✓ Branch 0 taken 97240 times.
✗ Branch 1 not taken.
97240 if(!p_getc(&(temp_mapscr->sidewarpoverlayflags),f,true))
15921 {
15922 return qe_invalid;
15923 }
15924 97240 }
15925 else
15926 {
15927 temp_mapscr->sidewarpoverlayflags=0;
15928 }
15929
15930
1/2
✓ Branch 0 taken 97240 times.
✗ Branch 1 not taken.
97240 if(!p_getc(&(temp_mapscr->warparrivalx),f,true))
15931 {
15932 return qe_invalid;
15933 }
15934
15935
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 97240 times.
97240 if(!p_getc(&(temp_mapscr->warparrivaly),f,true))
15936 {
15937 return qe_invalid;
15938 }
15939
15940
2/2
✓ Branch 0 taken 388960 times.
✓ Branch 1 taken 97240 times.
486200 for(int32_t k=0; k<4; k++)
15941 {
15942
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 388960 times.
388960 if(!p_getc(&(temp_mapscr->path[k]),f,true))
15943 {
15944 return qe_invalid;
15945 }
15946 388960 }
15947
15948
1/2
✓ Branch 0 taken 97240 times.
✗ Branch 1 not taken.
97240 if(!p_getc(&(temp_mapscr->sidewarpscr[0]),f,true))
15949 {
15950 return qe_invalid;
15951 }
15952
15953
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 97240 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
97240 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15954 {
15955
2/2
✓ Branch 0 taken 97240 times.
✓ Branch 1 taken 291720 times.
388960 for(int32_t i=1; i<4; i++)
15956 {
15957
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 291720 times.
291720 if(!p_getc(&(temp_mapscr->sidewarpscr[i]),f,true))
15958 {
15959 return qe_invalid;
15960 }
15961 291720 }
15962 97240 }
15963 else
15964 {
15965 temp_mapscr->sidewarpscr[1]=0;
15966 temp_mapscr->sidewarpscr[2]=0;
15967 temp_mapscr->sidewarpscr[3]=0;
15968 }
15969
15970
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 97240 times.
97240 if(version <= 11)
15971 {
15972 if(!p_getc(&(tempbyte),f,true))
15973 {
15974 return qe_invalid;
15975 }
15976
15977 temp_mapscr->sidewarpdmap[0]=(word)tempbyte;
15978
15979 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15980 {
15981 for(int32_t i=1; i<4; i++)
15982 {
15983 if(!p_getc(&(tempbyte),f,true))
15984 {
15985 return qe_invalid;
15986 }
15987
15988 temp_mapscr->sidewarpdmap[i]=(word)tempbyte;
15989 }
15990 }
15991 else
15992 {
15993 temp_mapscr->sidewarpdmap[1]=0;
15994 temp_mapscr->sidewarpdmap[2]=0;
15995 temp_mapscr->sidewarpdmap[3]=0;
15996 }
15997 }
15998 else
15999 {
16000
2/2
✓ Branch 0 taken 388960 times.
✓ Branch 1 taken 97240 times.
486200 for(int32_t i=0; i<4; i++)
16001 {
16002
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 388960 times.
388960 if(!p_igetw(&(temp_mapscr->sidewarpdmap[i]),f,true))
16003 {
16004 return qe_invalid;
16005 }
16006 388960 }
16007 }
16008
16009
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 97240 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
97240 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
16010 {
16011
1/2
✓ Branch 0 taken 97240 times.
✗ Branch 1 not taken.
97240 if(!p_getc(&(temp_mapscr->sidewarpindex),f,true))
16012 {
16013 return qe_invalid;
16014 }
16015 97240 }
16016 else temp_mapscr->sidewarpindex = 0;
16017
16018
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 97240 times.
97240 if(!p_igetw(&(temp_mapscr->undercombo),f,true))
16019 {
16020 return qe_invalid;
16021 }
16022
16023
1/2
✓ Branch 0 taken 97240 times.
✗ Branch 1 not taken.
97240 if(Header->zelda_version < 0x193)
16024 {
16025 if(!p_getc(&(temp_mapscr->old_cpage),f,true))
16026 {
16027 return qe_invalid;
16028 }
16029 }
16030
16031
1/2
✓ Branch 0 taken 97240 times.
✗ Branch 1 not taken.
97240 if(!p_getc(&(temp_mapscr->undercset),f,true)) //recalculated for older quests
16032 {
16033 return qe_invalid;
16034 }
16035
16036
1/2
✓ Branch 0 taken 97240 times.
✗ Branch 1 not taken.
97240 if(!p_igetw(&(temp_mapscr->catchall),f,true))
16037 {
16038 return qe_invalid;
16039 }
16040
16041
1/2
✓ Branch 0 taken 97240 times.
✗ Branch 1 not taken.
97240 if(!p_getc(&(temp_mapscr->flags),f,true))
16042 {
16043 return qe_invalid;
16044 }
16045
16046
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 97240 times.
97240 if(!p_getc(&(temp_mapscr->flags2),f,true))
16047 {
16048 return qe_invalid;
16049 }
16050
16051
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 97240 times.
97240 if(!p_getc(&(temp_mapscr->flags3),f,true))
16052 {
16053 return qe_invalid;
16054 }
16055
16056
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 97240 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
97240 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>1)))
16057 //if (version>2)
16058 {
16059
1/2
✓ Branch 0 taken 97240 times.
✗ Branch 1 not taken.
97240 if(!p_getc(&(temp_mapscr->flags4),f,true))
16060 {
16061 return qe_invalid;
16062 }
16063 97240 }
16064
16065
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 97240 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
97240 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
16066 {
16067
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 97240 times.
97240 if(!p_getc(&(temp_mapscr->flags5),f,true))
16068 {
16069 return qe_invalid;
16070 }
16071
16072
1/2
✓ Branch 0 taken 97240 times.
✗ Branch 1 not taken.
97240 if(!p_igetw(&(temp_mapscr->noreset),f,true))
16073 {
16074 return qe_invalid;
16075 }
16076
16077
1/2
✓ Branch 0 taken 97240 times.
✗ Branch 1 not taken.
97240 if(!p_igetw(&(temp_mapscr->nocarry),f,true))
16078 {
16079 return qe_invalid;
16080 }
16081
16082
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 97240 times.
97240 if(temp_mapscr->flags5&32)
16083 {
16084 temp_mapscr->flags5 &= ~32;
16085 temp_mapscr->noreset |= 48;
16086 }
16087
16088
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 97240 times.
97240 if(version<8)
16089 {
16090 if(temp_mapscr->noreset&1)
16091 {
16092 temp_mapscr->noreset|=8192;
16093 }
16094
16095 if(temp_mapscr->nocarry&1)
16096 {
16097 temp_mapscr->nocarry|=8192;
16098 temp_mapscr->nocarry&=~1;
16099 }
16100 }
16101 97240 }
16102 else
16103 {
16104 temp_mapscr->flags5 = 0;
16105 temp_mapscr->noreset = 0;
16106 temp_mapscr->nocarry = 0;
16107 }
16108
16109
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 97240 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
97240 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>9)))
16110 {
16111
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 97240 times.
97240 if(!p_getc(&(temp_mapscr->flags6),f,true))
16112 {
16113 return qe_invalid;
16114 }
16115 97240 }
16116
16117
1/2
✓ Branch 0 taken 97240 times.
✗ Branch 1 not taken.
97240 if(version>5)
16118 {
16119
1/2
✓ Branch 0 taken 97240 times.
✗ Branch 1 not taken.
97240 if(!p_getc(&(temp_mapscr->flags7),f,true))
16120 {
16121 return qe_invalid;
16122 }
16123
16124
1/2
✓ Branch 0 taken 97240 times.
✗ Branch 1 not taken.
97240 if(!p_getc(&(temp_mapscr->flags8),f,true))
16125 {
16126 return qe_invalid;
16127 }
16128
16129
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 97240 times.
97240 if(!p_getc(&(temp_mapscr->flags9),f,true))
16130 {
16131 return qe_invalid;
16132 }
16133
16134
1/2
✓ Branch 0 taken 97240 times.
✗ Branch 1 not taken.
97240 if(!p_getc(&(temp_mapscr->flags10),f,true))
16135 {
16136 return qe_invalid;
16137 }
16138
16139
1/2
✓ Branch 0 taken 97240 times.
✗ Branch 1 not taken.
97240 if(!p_getc(&(temp_mapscr->csensitive),f,true))
16140 {
16141 return qe_invalid;
16142 }
16143 97240 }
16144 else
16145 {
16146 temp_mapscr->csensitive=1;
16147 }
16148
16149
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 97240 times.
97240 if(version<14) // August 2007: screen SFX added
16150 {
16151 if(temp_mapscr->flags&8) //fROAR
16152 {
16153 temp_mapscr->bosssfx=
16154 (temp_mapscr->flags3&2) ? WAV_DODONGO : // fDODONGO
16155 (temp_mapscr->flags2&32) ? WAV_VADER : // fVADER
16156 WAV_ROAR;
16157 }
16158
16159 if(temp_mapscr->flags&128) //fSEA
16160 {
16161 temp_mapscr->oceansfx=WAV_SEA;
16162 }
16163
16164 if(!(temp_mapscr->flags3&64)) //fNOSECRETSOUND
16165 {
16166 temp_mapscr->secretsfx=WAV_SECRET;
16167 }
16168
16169 temp_mapscr->flags3 &= ~66; //64|2
16170 temp_mapscr->flags2 &= ~32;
16171 temp_mapscr->flags &= ~136; // 128|8
16172 }
16173 else
16174 {
16175
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 97240 times.
97240 if(!p_getc(&(temp_mapscr->oceansfx),f,true))
16176 {
16177 return qe_invalid;
16178 }
16179
16180
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 97240 times.
97240 if(!p_getc(&(temp_mapscr->bosssfx),f,true))
16181 {
16182 return qe_invalid;
16183 }
16184
16185
1/2
✓ Branch 0 taken 97240 times.
✗ Branch 1 not taken.
97240 if(!p_getc(&(temp_mapscr->secretsfx),f,true))
16186 {
16187 return qe_invalid;
16188 }
16189 }
16190
16191
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 97240 times.
97240 if(version<15) // October 2007: another SFX
16192 {
16193 temp_mapscr->holdupsfx=WAV_PICKUP;
16194 }
16195 else
16196 {
16197
1/2
✓ Branch 0 taken 97240 times.
✗ Branch 1 not taken.
97240 if(!p_getc(&(temp_mapscr->holdupsfx),f,true))
16198 {
16199 return qe_invalid;
16200 }
16201 }
16202
16203
16204
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 97240 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
97240 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>97)))
16205 {
16206
2/2
✓ Branch 0 taken 583440 times.
✓ Branch 1 taken 97240 times.
680680 for(int32_t k=0; k<6; k++)
16207 {
16208
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 583440 times.
583440 if(!p_getc(&(temp_mapscr->layermap[k]),f,true))
16209 {
16210 return qe_invalid;
16211 }
16212 583440 }
16213
16214
2/2
✓ Branch 0 taken 97240 times.
✓ Branch 1 taken 583440 times.
680680 for(int32_t k=0; k<6; k++)
16215 {
16216
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 583440 times.
583440 if(!p_getc(&(temp_mapscr->layerscreen[k]),f,true))
16217 {
16218 return qe_invalid;
16219 }
16220 583440 }
16221 97240 }
16222 else if((Header->zelda_version == 0x192)&&(Header->build>23)&&(Header->build<98))
16223 {
16224 if(!p_getc(&(temp_mapscr->layermap[2]),f,true))
16225 {
16226 return qe_invalid;
16227 }
16228
16229 if(!p_getc(&(temp_mapscr->layerscreen[2]),f,true))
16230 {
16231 return qe_invalid;
16232 }
16233
16234 if(!p_getc(&(temp_mapscr->layermap[4]),f,true))
16235 {
16236 return qe_invalid;
16237 }
16238
16239 if(!p_getc(&(temp_mapscr->layerscreen[4]),f,true))
16240
16241 {
16242 return qe_invalid;
16243 }
16244 }
16245
16246
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 97240 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
97240 if((Header->zelda_version == 0x192)&&(Header->build>149))
16247 {
16248 for(int32_t k=0; k<6; k++)
16249 {
16250 if(!p_getc(&tempbyte,f,true)) //layerxsize
16251 {
16252 return qe_invalid;
16253 }
16254 }
16255
16256 for(int32_t k=0; k<6; k++)
16257 {
16258 if(!p_getc(&tempbyte,f,true)) //layerxspeed
16259 {
16260 return qe_invalid;
16261 }
16262 }
16263
16264 for(int32_t k=0; k<6; k++)
16265 {
16266 if(!p_getc(&tempbyte,f,true)) //layerxdelay
16267 {
16268 return qe_invalid;
16269 }
16270 }
16271
16272 for(int32_t k=0; k<6; k++)
16273 {
16274 if(!p_getc(&tempbyte,f,true)) //layerysize
16275 {
16276 return qe_invalid;
16277 }
16278 }
16279
16280 for(int32_t k=0; k<6; k++)
16281 {
16282 if(!p_getc(&tempbyte,f,true)) //layeryspeed
16283 {
16284 return qe_invalid;
16285 }
16286 }
16287
16288 for(int32_t k=0; k<6; k++)
16289 {
16290 if(!p_getc(&tempbyte,f,true)) //layerydelay
16291 {
16292 return qe_invalid;
16293 }
16294 }
16295 }
16296
16297
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 97240 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
97240 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>149)))
16298 {
16299
2/2
✓ Branch 0 taken 583440 times.
✓ Branch 1 taken 97240 times.
680680 for(int32_t k=0; k<6; k++)
16300 {
16301
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 583440 times.
583440 if(!p_getc(&(temp_mapscr->layeropacity[k]),f,true))
16302 {
16303 return qe_invalid;
16304 }
16305 583440 }
16306 97240 }
16307
16308
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 97240 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
97240 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>153)))
16309 {
16310
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 97240 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
97240 if((Header->zelda_version == 0x192)&&(Header->build>153))
16311 {
16312 if(!p_getc(&padding,f,true))
16313 {
16314 return qe_invalid;
16315 }
16316 }
16317
16318
1/2
✓ Branch 0 taken 97240 times.
✗ Branch 1 not taken.
97240 if(!p_igetw(&(temp_mapscr->timedwarptics),f,true))
16319 {
16320 return qe_invalid;
16321 }
16322 97240 }
16323
16324
2/6
✓ Branch 0 taken 97240 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 97240 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
97240 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<24)))
16325 {
16326 extras=15;
16327 }
16328
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 97240 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
97240 else if(((Header->zelda_version == 0x192)&&(Header->build<98)))
16329 {
16330 extras=11;
16331 }
16332
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 97240 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
97240 else if((Header->zelda_version == 0x192)&&(Header->build<150))
16333 {
16334 extras=32;
16335 }
16336
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 97240 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
97240 else if((Header->zelda_version == 0x192)&&(Header->build<154))
16337 {
16338 extras=64;
16339 }
16340
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 97240 times.
97240 else if(Header->zelda_version < 0x193)
16341 {
16342 extras=62;
16343 }
16344 else
16345
16346 {
16347 97240 extras=0;
16348 }
16349
16350
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 97240 times.
97240 for(int32_t k=0; k<extras; k++)
16351 {
16352 if(!p_getc(&tempbyte,f,true)) //extra[k]
16353 {
16354 return qe_invalid;
16355 }
16356 }
16357
16358
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 97240 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
97240 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>2)))
16359 //if (version>3)
16360 {
16361
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 97240 times.
97240 if(!p_getc(&(temp_mapscr->nextmap),f,true))
16362 {
16363 return qe_invalid;
16364 }
16365
16366
1/2
✓ Branch 0 taken 97240 times.
✗ Branch 1 not taken.
97240 if(!p_getc(&(temp_mapscr->nextscr),f,true))
16367 {
16368 return qe_invalid;
16369 }
16370 97240 }
16371 else
16372 {
16373 temp_mapscr->nextmap=0;
16374 temp_mapscr->nextscr=0;
16375 }
16376
16377
2/6
✓ Branch 0 taken 97240 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 97240 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
97240 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
16378 {
16379 secretcombos=20;
16380 }
16381
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 97240 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
97240 else if((Header->zelda_version == 0x192)&&(Header->build<154))
16382 {
16383 secretcombos=256;
16384 }
16385 else
16386 {
16387 97240 secretcombos=128;
16388 }
16389
16390
2/6
✓ Branch 0 taken 97240 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 97240 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
97240 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
16391 {
16392 for(int32_t k=0; k<secretcombos; k++)
16393 {
16394 if(!p_getc(&tempbyte,f,true))
16395 {
16396 return qe_invalid;
16397 }
16398
16399 if(k<128)
16400 {
16401 temp_mapscr->secretcombo[k]=tempbyte;
16402 }
16403 }
16404 }
16405 else
16406 {
16407
2/2
✓ Branch 0 taken 12446720 times.
✓ Branch 1 taken 97240 times.
12543960 for(int32_t k=0; k<128; k++)
16408 {
16409
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12446720 times.
12446720 if(!p_igetw(&(temp_mapscr->secretcombo[k]),f,true))
16410 {
16411 return qe_invalid;
16412 }
16413
16414 12446720 }
16415 }
16416
16417
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 97240 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
97240 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>153)))
16418 {
16419
2/2
✓ Branch 0 taken 12446720 times.
✓ Branch 1 taken 97240 times.
12543960 for(int32_t k=0; k<128; k++)
16420 {
16421
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12446720 times.
12446720 if(!p_getc(&(temp_mapscr->secretcset[k]),f,true))
16422 {
16423 return qe_invalid;
16424 }
16425 12446720 }
16426
16427
2/2
✓ Branch 0 taken 12446720 times.
✓ Branch 1 taken 97240 times.
12543960 for(int32_t k=0; k<128; k++)
16428 {
16429
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12446720 times.
12446720 if(!p_getc(&(temp_mapscr->secretflag[k]),f,true))
16430 {
16431 return qe_invalid;
16432 }
16433 12446720 }
16434 97240 }
16435
16436
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 97240 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
97240 if((Header->zelda_version == 0x192)&&(Header->build>97)&&(Header->build<154))
16437 {
16438 if(!p_getc(&padding,f,true))
16439 {
16440 return qe_invalid;
16441 }
16442 }
16443
16444 97240 const int32_t _mapsSize = (temp_map->tileWidth*temp_map->tileHeight);
16445
16446
2/2
✓ Branch 0 taken 17114240 times.
✓ Branch 1 taken 97240 times.
17211480 for(int32_t k=0; k<(temp_map->tileWidth*temp_map->tileHeight); k++)
16447 {
16448
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17114240 times.
17114240 if(!p_igetw(&(temp_mapscr->data[k]),f,true))
16449 {
16450 return qe_invalid;
16451 }
16452 17114240 }
16453
16454
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 97240 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
97240 if((Header->zelda_version == 0x192)&&(Header->build>20)&&(Header->build<24))
16455 {
16456 if(!p_getc(&padding,f,true))
16457 {
16458 return qe_invalid;
16459 }
16460
16461 if(!p_getc(&padding,f,true))
16462 {
16463 return qe_invalid;
16464 }
16465 }
16466
16467
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 97240 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
97240 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>20)))
16468 {
16469
2/2
✓ Branch 0 taken 17114240 times.
✓ Branch 1 taken 97240 times.
17211480 for(int32_t k=0; k<(temp_map->tileWidth*temp_map->tileHeight); k++)
16470 {
16471
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17114240 times.
17114240 if(!p_getc(&(temp_mapscr->sflag[k]),f,true))
16472 {
16473 return qe_invalid;
16474 }
16475
16476
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 17114240 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
17114240 if((Header->zelda_version == 0x192)&&(Header->build<24))
16477 {
16478 if(!p_getc(&tempbyte,f,true))
16479 {
16480 return qe_invalid;
16481 }
16482
16483 if(!p_getc(&tempbyte,f,true))
16484 {
16485 return qe_invalid;
16486 }
16487
16488 if(!p_getc(&tempbyte,f,true))
16489 {
16490 return qe_invalid;
16491 }
16492 }
16493 17114240 }
16494 97240 }
16495
16496
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 97240 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
97240 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>97)))
16497 {
16498
2/2
✓ Branch 0 taken 97240 times.
✓ Branch 1 taken 17114240 times.
17211480 for(int32_t k=0; k<(temp_map->tileWidth*temp_map->tileHeight); k++)
16499 {
16500
16501
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17114240 times.
17114240 if(!p_getc(&(temp_mapscr->cset[k]),f,true))
16502 {
16503 return qe_invalid;
16504 }
16505 17114240 }
16506 97240 }
16507
16508
2/6
✓ Branch 0 taken 97240 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 97240 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
97240 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
16509 {
16510 temp_mapscr->undercset=(temp_mapscr->undercombo>>8)&7;
16511 temp_mapscr->undercombo=(temp_mapscr->undercombo&0xFF)+(temp_mapscr->old_cpage<<8);
16512 }
16513
16514
2/6
✓ Branch 0 taken 97240 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 97240 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
97240 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
16515 {
16516 temp_mapscr->secretcombo[sSBOMB]=temp_mapscr->secretcombo[sBOMB];
16517 temp_mapscr->secretcombo[sRCANDLE]=temp_mapscr->secretcombo[sBCANDLE];
16518 temp_mapscr->secretcombo[sWANDFIRE]=temp_mapscr->secretcombo[sBCANDLE];
16519 temp_mapscr->secretcombo[sDINSFIRE]=temp_mapscr->secretcombo[sBCANDLE];
16520 temp_mapscr->secretcombo[sSARROW]=temp_mapscr->secretcombo[sARROW];
16521 temp_mapscr->secretcombo[sGARROW]=temp_mapscr->secretcombo[sARROW];
16522 }
16523
16524
2/6
✓ Branch 0 taken 97240 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 97240 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
97240 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
16525 {
16526 for(int32_t k=0; k<(temp_map->tileWidth*temp_map->tileHeight); k++)
16527 {
16528 if((Header->zelda_version == 0x192)&&(Header->build>149))
16529 {
16530 if((Header->zelda_version == 0x192)&&(Header->build!=153))
16531 {
16532 temp_mapscr->cset[k]=((temp_mapscr->data[k]>>8)&7);
16533 }
16534 }
16535 else
16536 {
16537 if((Header->zelda_version < 0x192)||
16538 ((Header->zelda_version == 0x192)&&(Header->build<21)))
16539 {
16540 temp_mapscr->sflag[k]=(temp_mapscr->data[k]>>11);
16541 }
16542
16543 temp_mapscr->cset[k]=((temp_mapscr->data[k]>>8)&7);
16544 }
16545
16546 temp_mapscr->data[k]=(temp_mapscr->data[k]&0xFF)+(temp_mapscr->old_cpage<<8);
16547 }
16548 }
16549
16550 /*if(version>12)
16551 {
16552 if(!p_getc(&(temp_mapscr->scrWidth),f,true))
16553 {
16554 return qe_invalid;
16555 }
16556 if(!p_getc(&(temp_mapscr->scrHeight),f,true))
16557 {
16558 return qe_invalid;
16559 }
16560 }*/
16561
16562
1/2
✓ Branch 0 taken 97240 times.
✗ Branch 1 not taken.
97240 if(version>4)
16563 {
16564
1/2
✓ Branch 0 taken 97240 times.
✗ Branch 1 not taken.
97240 if(!p_igetw(&(temp_mapscr->screen_midi),f,true))
16565 {
16566 return qe_invalid;
16567 }
16568 97240 }
16569 else
16570 {
16571 temp_mapscr->screen_midi = -1;
16572 }
16573
16574
1/2
✓ Branch 0 taken 97240 times.
✗ Branch 1 not taken.
97240 if(version>=17)
16575 {
16576
1/2
✓ Branch 0 taken 97240 times.
✗ Branch 1 not taken.
97240 if(!p_getc(&(temp_mapscr->lens_layer),f,true))
16577 {
16578 return qe_invalid;
16579 }
16580 97240 }
16581 else
16582 {
16583 temp_mapscr->lens_layer = llNORMAL;
16584 }
16585
16586
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 97240 times.
97240 if(version>6)
16587 {
16588 dword bits;
16589
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 97240 times.
97240 if(!p_igetl(&bits,f,true))
16590 {
16591 return qe_invalid;
16592 }
16593
16594 int32_t m;
16595 float tempfloat;
16596 word tempw;
16597
16598
2/2
✓ Branch 0 taken 97240 times.
✓ Branch 1 taken 3111680 times.
3208920 for(m=0; m<32; m++)
16599 {
16600 3111680 ffcdata& tempffc = temp_mapscr->ffcs[m];
16601 3111680 tempffc.clear();
16602
2/2
✓ Branch 0 taken 3104277 times.
✓ Branch 1 taken 7403 times.
3111680 if((bits>>m)&1)
16603 {
16604
1/2
✓ Branch 0 taken 7403 times.
✗ Branch 1 not taken.
7403 if(!p_igetw(&tempw,f,true))
16605 {
16606 return qe_invalid;
16607 }
16608 7403 tempffc.setData(tempw);
16609
16610
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7403 times.
7403 if(!p_getc(&(tempffc.cset),f,true))
16611 {
16612 return qe_invalid;
16613 }
16614
16615
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7403 times.
7403 if(!p_igetw(&(tempffc.delay),f,true))
16616 {
16617 return qe_invalid;
16618 }
16619
16620
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7403 times.
7403 if(version < 9)
16621 {
16622 if(!p_igetf(&tempfloat,f,true))
16623 {
16624 return qe_invalid;
16625 }
16626
16627 tempffc.x=zslongToFix(int32_t(tempfloat*10000));
16628
16629 if(!p_igetf(&tempfloat,f,true))
16630 {
16631 return qe_invalid;
16632 }
16633
16634 tempffc.y=zslongToFix(int32_t(tempfloat*10000));
16635
16636 if(!p_igetf(&tempfloat,f,true))
16637 {
16638 return qe_invalid;
16639 }
16640
16641 tempffc.vx=zslongToFix(int32_t(tempfloat*10000));
16642
16643 if(!p_igetf(&tempfloat,f,true))
16644 {
16645 return qe_invalid;
16646 }
16647
16648 tempffc.vy=zslongToFix(int32_t(tempfloat*10000));
16649
16650 if(!p_igetf(&tempfloat,f,true))
16651 {
16652 return qe_invalid;
16653 }
16654
16655 tempffc.ax=zslongToFix(int32_t(tempfloat*10000));
16656
16657 if(!p_igetf(&tempfloat,f,true))
16658 {
16659 return qe_invalid;
16660 }
16661
16662 tempffc.ay=zslongToFix(int32_t(tempfloat*10000));
16663 }
16664 else
16665 {
16666
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7403 times.
7403 if(!p_igetzf(&(tempffc.x),f,true))
16667 {
16668 return qe_invalid;
16669 }
16670
16671
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7403 times.
7403 if(!p_igetzf(&(tempffc.y),f,true))
16672 {
16673 return qe_invalid;
16674 }
16675
16676
1/2
✓ Branch 0 taken 7403 times.
✗ Branch 1 not taken.
7403 if(!p_igetzf(&(tempffc.vx),f,true))
16677 {
16678 return qe_invalid;
16679 }
16680
16681
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7403 times.
7403 if(!p_igetzf(&(tempffc.vy),f,true))
16682 {
16683 return qe_invalid;
16684 }
16685
16686
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7403 times.
7403 if(!p_igetzf(&(tempffc.ax),f,true))
16687 {
16688 return qe_invalid;
16689 }
16690
16691
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7403 times.
7403 if(!p_igetzf(&(tempffc.ay),f,true))
16692 {
16693 return qe_invalid;
16694 }
16695 }
16696
16697
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7403 times.
7403 if(!p_getc(&(tempffc.link),f,true))
16698 {
16699 return qe_invalid;
16700 }
16701
16702
1/2
✓ Branch 0 taken 7403 times.
✗ Branch 1 not taken.
7403 if(version>7)
16703 {
16704
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7403 times.
7403 if(!p_getc(&tempbyte,f,true))
16705 {
16706 return qe_invalid;
16707 }
16708
16709 7403 tempffc.hxsz = (tempbyte&0x3F)+1;
16710 7403 tempffc.txsz = (tempbyte>>6)+1;
16711
16712
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7403 times.
7403 if(!p_getc(&tempbyte,f,true))
16713 {
16714 return qe_invalid;
16715 }
16716
16717 7403 tempffc.hysz = (tempbyte&0x3F)+1;
16718 7403 tempffc.tysz = (tempbyte>>6)+1;
16719
16720
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7403 times.
7403 if(!p_igetl(&(tempffc.flags),f,true))
16721 {
16722 return qe_invalid;
16723 }
16724 7403 }
16725 else
16726 {
16727 tempffc.hxsz=16;
16728 tempffc.hysz=16;
16729 tempffc.txsz=1;
16730 tempffc.tysz=1;
16731 tempffc.flags=0;
16732 }
16733
16734 7403 tempffc.updateSolid();
16735
16736
16737
3/6
✓ Branch 0 taken 7403 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7403 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 7403 times.
7403 if(Header->zelda_version == 0x211 || (Header->zelda_version == 0x250 && Header->build<20))
16738 {
16739 tempffc.flags|=ffIGNOREHOLDUP;
16740 }
16741
16742
1/2
✓ Branch 0 taken 7403 times.
✗ Branch 1 not taken.
7403 if(version>9)
16743 {
16744
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7403 times.
7403 if(!p_igetw(&(tempffc.script),f,true))
16745 {
16746 return qe_invalid;
16747 }
16748 7403 }
16749 else
16750 {
16751 tempffc.script=0;
16752 }
16753
16754
1/2
✓ Branch 0 taken 7403 times.
✗ Branch 1 not taken.
7403 if(version>10)
16755 {
16756
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7403 times.
7403 if(!p_igetl(&(tempffc.initd[0]),f,true))
16757 {
16758 return qe_invalid;
16759 }
16760
16761
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7403 times.
7403 if(!p_igetl(&(tempffc.initd[1]),f,true))
16762 {
16763 return qe_invalid;
16764 }
16765
16766
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7403 times.
7403 if(!p_igetl(&(tempffc.initd[2]),f,true))
16767 {
16768 return qe_invalid;
16769 }
16770
16771
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7403 times.
7403 if(!p_igetl(&(tempffc.initd[3]),f,true))
16772 {
16773 return qe_invalid;
16774 }
16775
16776
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7403 times.
7403 if(!p_igetl(&(tempffc.initd[4]),f,true))
16777 {
16778 return qe_invalid;
16779 }
16780
16781
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7403 times.
7403 if(!p_igetl(&(tempffc.initd[5]),f,true))
16782 {
16783 return qe_invalid;
16784 }
16785
16786
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7403 times.
7403 if(!p_igetl(&(tempffc.initd[6]),f,true))
16787 {
16788 return qe_invalid;
16789 }
16790
16791
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7403 times.
7403 if(!p_igetl(&(tempffc.initd[7]),f,true))
16792 {
16793 return qe_invalid;
16794 }
16795
16796
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7403 times.
7403 if(!p_getc(&(tempbyte),f,true))
16797 {
16798 return qe_invalid;
16799 }
16800
16801 7403 tempffc.inita[0]=tempbyte*10000;
16802
16803
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7403 times.
7403 if(!p_getc(&(tempbyte),f,true))
16804 {
16805 return qe_invalid;
16806 }
16807
16808 7403 tempffc.inita[1]=tempbyte*10000;
16809 7403 }
16810 else
16811 {
16812 tempffc.inita[0] = 10000;
16813 tempffc.inita[1] = 10000;
16814 }
16815
16816 7403 tempffc.initialized = false;
16817
16818
1/2
✓ Branch 0 taken 7403 times.
✗ Branch 1 not taken.
7403 if(version <= 11)
16819 {
16820 fixffcs=true;
16821 }
16822 7403 }
16823 3111680 }
16824
16825 97240 }
16826
16827 //add in the new whistle flags
16828
1/2
✓ Branch 0 taken 97240 times.
✗ Branch 1 not taken.
97240 if(version<13)
16829 {
16830 if(temp_mapscr->flags & fWHISTLE)
16831 {
16832 temp_mapscr->flags7 |= (fWHISTLEPAL | fWHISTLEWATER);
16833 }
16834 }
16835
16836 // for(int32_t m=0; m<32; m++)
16837 // {
16838 // // ffcScriptData used to be part of mapscr, and this was handled just above
16839 // ffcScriptData[m].a[0] = 10000;
16840 // ffcScriptData[m].a[1] = 10000;
16841 // }
16842
16843 //2.55 starts here
16844
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 97240 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
97240 if ( version >= 19 && Header->zelda_version > 0x253 )
16845 {
16846 for ( int32_t q = 0; q < 10; q++ )
16847 {
16848 if(!p_igetl(&(temp_mapscr->npcstrings[q]),f,true))
16849 {
16850 return qe_invalid;
16851 }
16852 }
16853 for ( int32_t q = 0; q < 10; q++ )
16854 {
16855 if(!p_igetw(&(temp_mapscr->new_items[q]),f,true))
16856 {
16857 return qe_invalid;
16858 }
16859 }
16860 for ( int32_t q = 0; q < 10; q++ )
16861 {
16862 if(!p_igetw(&(temp_mapscr->new_item_x[q]),f,true))
16863 {
16864 return qe_invalid;
16865 }
16866 }
16867 for ( int32_t q = 0; q < 10; q++ )
16868 {
16869 if(!p_igetw(&(temp_mapscr->new_item_y[q]),f,true))
16870 {
16871 return qe_invalid;
16872 }
16873 }
16874 }
16875
2/4
✓ Branch 0 taken 97240 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 97240 times.
97240 if ( version < 19 && Header->zelda_version > 0x253 )
16876 {
16877 for ( int32_t q = 0; q < 10; q++ )
16878 {
16879 temp_mapscr->npcstrings[q] = 0;
16880 temp_mapscr->new_items[q] = 0;
16881 temp_mapscr->new_item_x[q] = 0;
16882 temp_mapscr->new_item_y[q] = 0;
16883 }
16884 }
16885
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 97240 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
97240 if ( version >= 20 && Header->zelda_version > 0x253 )
16886 {
16887 if(!p_igetw(&(temp_mapscr->script),f,true))
16888 {
16889 return qe_invalid;
16890 }
16891 for ( int32_t q = 0; q < 8; q++)
16892 {
16893 if(!p_igetl(&(temp_mapscr->screeninitd[q]),f,true))
16894 {
16895 return qe_invalid;
16896 }
16897 }
16898 }
16899
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 97240 times.
97240 if ( version < 20 )
16900 {
16901 97240 temp_mapscr->script = 0;
16902
2/2
✓ Branch 0 taken 777920 times.
✓ Branch 1 taken 97240 times.
875160 for ( int32_t q = 0; q < 8; q++) temp_mapscr->screeninitd[q] = 0;
16903 97240 }
16904
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 97240 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
97240 if ( version >= 21 && Header->zelda_version > 0x253 )
16905 {
16906 if(!p_getc(&(temp_mapscr->preloadscript),f,true))
16907 {
16908 return qe_invalid;
16909 }
16910 }
16911
1/2
✓ Branch 0 taken 97240 times.
✗ Branch 1 not taken.
97240 if ( version < 21 )
16912 {
16913 97240 temp_mapscr->preloadscript = 0;
16914 97240 }
16915 //all builds with version > 20 need this. -Z
16916 97240 temp_mapscr->ffcswaitdraw = 0;
16917
16918
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 97240 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
97240 if ( version >= 22 && Header->zelda_version > 0x253 ) //26th June, 2019; Layer Visibility
16919 {
16920 if(!p_getc(&(temp_mapscr->hidelayers ),f,true))
16921 {
16922 return qe_invalid;
16923 }
16924 if(!p_getc(&(temp_mapscr->hidescriptlayers ),f,true))
16925 {
16926 return qe_invalid;
16927 }
16928 }
16929
1/2
✓ Branch 0 taken 97240 times.
✗ Branch 1 not taken.
97240 if ( version < 22 )
16930 {
16931 97240 temp_mapscr->hidelayers = 0;
16932 97240 temp_mapscr->hidescriptlayers = 0;
16933 97240 }
16934
16935 //Dodongos in 2.10 used the boss roar, not the dodongo sound. -Z
16936 //May be any version before 2.11. -Z
16937 /* --not the roar, the HIT SFX
16938 if ( Header->zelda_version <= 0x210 )
16939 {
16940 if ( temp_mapscr->bosssfx == WAV_DODONGO )
16941 {
16942 temp_mapscr->bosssfx = WAV_ROAR;
16943 }
16944 }
16945 */
16946
16947 97240 return 0;
16948 97240 }
16949 98056 int32_t readmapscreen(PACKFILE *f, zquestheader *Header, mapscr *temp_mapscr, zcmap *temp_map, word version)
16950 {
16951
2/2
✓ Branch 0 taken 97240 times.
✓ Branch 1 taken 816 times.
98056 if(version < 23)
16952 {
16953 97240 auto ret = readmapscreen_old(f,Header,temp_mapscr,temp_map,version);
16954
1/2
✓ Branch 0 taken 97240 times.
✗ Branch 1 not taken.
97240 if(ret) return ret;
16955 97240 temp_mapscr->update_ffc_count(31);
16956 97240 }
16957 else
16958 {
16959
1/2
✓ Branch 0 taken 816 times.
✗ Branch 1 not taken.
816 if(!p_getc(&(temp_mapscr->valid),f,true))
16960 return qe_invalid;
16961
2/2
✓ Branch 0 taken 47 times.
✓ Branch 1 taken 769 times.
816 if(!(temp_mapscr->valid & mVALID))
16962 769 return 0; //Empty screen
16963 uint32_t scr_has_flags;
16964
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 47 times.
47 if(!p_igetl(&scr_has_flags,f,true))
16965 return qe_invalid;
16966
16967
1/2
✓ Branch 0 taken 47 times.
✗ Branch 1 not taken.
47 if(scr_has_flags & SCRHAS_ROOMDATA)
16968 {
16969 if(!p_getc(&(temp_mapscr->guy),f,true))
16970 return qe_invalid;
16971 if(!p_igetw(&(temp_mapscr->str),f,true))
16972 return qe_invalid;
16973 if(!p_getc(&(temp_mapscr->room),f,true))
16974 return qe_invalid;
16975 if(!p_igetw(&(temp_mapscr->catchall),f,true))
16976 return qe_invalid;
16977 }
16978
2/2
✓ Branch 0 taken 46 times.
✓ Branch 1 taken 1 times.
47 if(scr_has_flags & SCRHAS_ITEM)
16979 {
16980
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!p_getc(&(temp_mapscr->item),f,true))
16981 return qe_invalid;
16982
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(!p_getc(&(temp_mapscr->hasitem),f,true))
16983 return qe_invalid;
16984
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!p_getc(&(temp_mapscr->itemx),f,true))
16985 return qe_invalid;
16986
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!p_getc(&(temp_mapscr->itemy),f,true))
16987 return qe_invalid;
16988 1 }
16989
2/2
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 5 times.
47 if(scr_has_flags & (SCRHAS_SWARP|SCRHAS_TWARP))
16990 {
16991
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(!p_igetw(&temp_mapscr->warpreturnc,f,true))
16992 return qe_invalid;
16993 5 }
16994
2/2
✓ Branch 0 taken 46 times.
✓ Branch 1 taken 1 times.
47 if(scr_has_flags & SCRHAS_TWARP)
16995 {
16996
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
5 for(int32_t i=0; i<4; i++)
16997 {
16998
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(!p_getc(&(temp_mapscr->tilewarptype[i]),f,true))
16999 return qe_invalid;
17000 4 }
17001
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
5 for(int32_t i=0; i<4; i++)
17002 {
17003
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(!p_igetw(&(temp_mapscr->tilewarpdmap[i]),f,true))
17004 return qe_invalid;
17005 4 }
17006
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
5 for(int32_t i=0; i<4; i++)
17007 {
17008
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(!p_getc(&(temp_mapscr->tilewarpscr[i]),f,true))
17009 return qe_invalid;
17010 4 }
17011
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!p_getc(&(temp_mapscr->tilewarpoverlayflags),f,true))
17012 return qe_invalid;
17013 1 }
17014
2/2
✓ Branch 0 taken 43 times.
✓ Branch 1 taken 4 times.
47 if(scr_has_flags & SCRHAS_SWARP)
17015 {
17016
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 4 times.
20 for(int32_t i=0; i<4; i++)
17017 {
17018
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if(!p_getc(&(temp_mapscr->sidewarptype[i]),f,true))
17019 return qe_invalid;
17020 16 }
17021
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 4 times.
20 for(int32_t i=0; i<4; i++)
17022 {
17023
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if(!p_igetw(&(temp_mapscr->sidewarpdmap[i]),f,true))
17024 return qe_invalid;
17025 16 }
17026
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 4 times.
20 for(int32_t i=0; i<4; i++)
17027 {
17028
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if(!p_getc(&(temp_mapscr->sidewarpscr[i]),f,true))
17029 return qe_invalid;
17030 16 }
17031
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&(temp_mapscr->sidewarpoverlayflags),f,true))
17032 return qe_invalid;
17033
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&(temp_mapscr->sidewarpindex),f,true))
17034 return qe_invalid;
17035 4 }
17036
2/2
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 8 times.
47 if(scr_has_flags & SCRHAS_WARPRET)
17037 {
17038
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 8 times.
40 for(int32_t i=0; i<4; i++)
17039 {
17040
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
32 if(!p_getc(&(temp_mapscr->warpreturnx[i]),f,true))
17041 return qe_invalid;
17042 32 }
17043
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 8 times.
40 for(int32_t i=0; i<4; i++)
17044 {
17045
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
32 if(!p_getc(&(temp_mapscr->warpreturny[i]),f,true))
17046 return qe_invalid;
17047 32 }
17048
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!p_getc(&(temp_mapscr->warparrivalx),f,true))
17049 return qe_invalid;
17050
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!p_getc(&(temp_mapscr->warparrivaly),f,true))
17051 return qe_invalid;
17052 8 }
17053
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 38 times.
47 if(scr_has_flags & SCRHAS_LAYERS)
17054 {
17055
2/2
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 9 times.
63 for(int32_t k=0; k<6; k++)
17056 {
17057
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 54 times.
54 if(!p_getc(&(temp_mapscr->layermap[k]),f,true))
17058 return qe_invalid;
17059 54 }
17060
2/2
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 9 times.
63 for(int32_t k=0; k<6; k++)
17061 {
17062
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 54 times.
54 if(!p_getc(&(temp_mapscr->layerscreen[k]),f,true))
17063 return qe_invalid;
17064 54 }
17065
2/2
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 9 times.
63 for(int32_t k=0; k<6; k++)
17066 {
17067
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 54 times.
54 if(!p_getc(&(temp_mapscr->layeropacity[k]),f,true))
17068 return qe_invalid;
17069 54 }
17070
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&(temp_mapscr->hidelayers),f,true))
17071 return qe_invalid;
17072
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&(temp_mapscr->hidescriptlayers),f,true))
17073 return qe_invalid;
17074 9 }
17075 else
17076 {
17077
2/2
✓ Branch 0 taken 228 times.
✓ Branch 1 taken 38 times.
266 for(int32_t k=0; k<6; k++)
17078 {
17079 228 temp_mapscr->layeropacity[k] = 255;
17080 228 }
17081 }
17082
1/2
✓ Branch 0 taken 47 times.
✗ Branch 1 not taken.
47 if(scr_has_flags & SCRHAS_MAZE)
17083 {
17084 for(int32_t k=0; k<4; k++)
17085 {
17086 if(!p_getc(&(temp_mapscr->path[k]),f,true))
17087 return qe_invalid;
17088 }
17089 if(!p_getc(&(temp_mapscr->exitdir),f,true))
17090 return qe_invalid;
17091 }
17092
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 12 times.
47 if(scr_has_flags & SCRHAS_D_S_U)
17093 {
17094
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetw(&(temp_mapscr->door_combo_set),f,true))
17095 return qe_invalid;
17096
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 12 times.
60 for(int32_t k=0; k<4; k++)
17097 {
17098
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if(!p_getc(&(temp_mapscr->door[k]),f,true))
17099 return qe_invalid;
17100 48 }
17101
17102
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&(temp_mapscr->stairx),f,true))
17103 return qe_invalid;
17104
17105
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&(temp_mapscr->stairy),f,true))
17106 return qe_invalid;
17107
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!p_igetw(&(temp_mapscr->undercombo),f,true))
17108 return qe_invalid;
17109
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&(temp_mapscr->undercset),f,true))
17110 return qe_invalid;
17111 12 }
17112
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 15 times.
47 if(scr_has_flags & SCRHAS_FLAGS)
17113 {
17114
1/2
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
15 if(!p_getc(&(temp_mapscr->flags),f,true))
17115 return qe_invalid;
17116
1/2
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
15 if(!p_getc(&(temp_mapscr->flags2),f,true))
17117 return qe_invalid;
17118
1/2
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
15 if(!p_getc(&(temp_mapscr->flags3),f,true))
17119 return qe_invalid;
17120
1/2
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
15 if(!p_getc(&(temp_mapscr->flags4),f,true))
17121 return qe_invalid;
17122
1/2
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
15 if(!p_getc(&(temp_mapscr->flags5),f,true))
17123 return qe_invalid;
17124
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
15 if(!p_getc(&(temp_mapscr->flags6),f,true))
17125 return qe_invalid;
17126
1/2
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
15 if(!p_getc(&(temp_mapscr->flags7),f,true))
17127 return qe_invalid;
17128
1/2
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
15 if(!p_getc(&(temp_mapscr->flags8),f,true))
17129 return qe_invalid;
17130
1/2
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
15 if(!p_getc(&(temp_mapscr->flags9),f,true))
17131 return qe_invalid;
17132
1/2
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
15 if(!p_getc(&(temp_mapscr->flags10),f,true))
17133 return qe_invalid;
17134
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
15 if(!p_getc(&(temp_mapscr->enemyflags),f,true))
17135 return qe_invalid;
17136 15 }
17137
2/2
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 3 times.
47 if(scr_has_flags & SCRHAS_ENEMY)
17138 {
17139
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 3 times.
33 for(int32_t k=0; k<10; k++)
17140 {
17141
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if(!p_igetw(&(temp_mapscr->enemy[k]),f,true))
17142 return qe_invalid;
17143
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if (unsigned(temp_mapscr->enemy[k]) > MAXGUYS)
17144 temp_mapscr->enemy[k] = 0;
17145 30 }
17146
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_getc(&(temp_mapscr->pattern),f,true))
17147 return qe_invalid;
17148 3 }
17149
1/2
✓ Branch 0 taken 47 times.
✗ Branch 1 not taken.
47 if(scr_has_flags & SCRHAS_CARRY)
17150 {
17151 if(!p_igetw(&(temp_mapscr->noreset),f,true))
17152 return qe_invalid;
17153 if(!p_igetw(&(temp_mapscr->nocarry),f,true))
17154 return qe_invalid;
17155 if(!p_getc(&(temp_mapscr->nextmap),f,true))
17156 return qe_invalid;
17157 if(!p_getc(&(temp_mapscr->nextscr),f,true))
17158 return qe_invalid;
17159 }
17160
1/2
✓ Branch 0 taken 47 times.
✗ Branch 1 not taken.
47 if(scr_has_flags & SCRHAS_SCRIPT)
17161 {
17162 if(!p_igetw(&(temp_mapscr->script),f,true))
17163 return qe_invalid;
17164 if(!p_getc(&(temp_mapscr->preloadscript),f,true))
17165 return qe_invalid;
17166 for ( int32_t q = 0; q < 8; q++ )
17167 {
17168 if(!p_igetl(&(temp_mapscr->screeninitd[q]),f,true))
17169 return qe_invalid;
17170 }
17171 }
17172
1/2
✓ Branch 0 taken 47 times.
✗ Branch 1 not taken.
47 if(scr_has_flags & SCRHAS_UNUSED)
17173 {
17174 for ( int32_t q = 0; q < 10; q++ )
17175 {
17176 if(!p_igetl(&(temp_mapscr->npcstrings[q]),f,true))
17177 return qe_invalid;
17178 }
17179 for ( int32_t q = 0; q < 10; q++ )
17180 {
17181 if(!p_igetw(&(temp_mapscr->new_items[q]),f,true))
17182 return qe_invalid;
17183 }
17184 for ( int32_t q = 0; q < 10; q++ )
17185 {
17186 if(!p_igetw(&(temp_mapscr->new_item_x[q]),f,true))
17187 return qe_invalid;
17188 }
17189 for ( int32_t q = 0; q < 10; q++ )
17190 {
17191 if(!p_igetw(&(temp_mapscr->new_item_y[q]),f,true))
17192 return qe_invalid;
17193 }
17194 }
17195
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 12 times.
47 if(scr_has_flags & SCRHAS_SECRETS)
17196 {
17197
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 12 times.
1548 for(int32_t k=0; k<128; k++)
17198 {
17199
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1536 times.
1536 if(!p_igetw(&(temp_mapscr->secretcombo[k]),f,true))
17200 return qe_invalid;
17201 1536 }
17202
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 12 times.
1548 for(int32_t k=0; k<128; k++)
17203 {
17204
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1536 times.
1536 if(!p_getc(&(temp_mapscr->secretcset[k]),f,true))
17205 return qe_invalid;
17206 1536 }
17207
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 12 times.
1548 for(int32_t k=0; k<128; k++)
17208 {
17209
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1536 times.
1536 if(!p_getc(&(temp_mapscr->secretflag[k]),f,true))
17210 return qe_invalid;
17211 1536 }
17212 12 }
17213
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 47 times.
47 if(scr_has_flags & SCRHAS_COMBOFLAG)
17214 {
17215
2/2
✓ Branch 0 taken 8272 times.
✓ Branch 1 taken 47 times.
8319 for(int32_t k=0; k<176; ++k)
17216 {
17217
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8272 times.
8272 if(!p_igetw(&(temp_mapscr->data[k]),f,true))
17218 return qe_invalid;
17219 8272 }
17220
2/2
✓ Branch 0 taken 8272 times.
✓ Branch 1 taken 47 times.
8319 for(int32_t k=0; k<176; ++k)
17221 {
17222
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8272 times.
8272 if(!p_getc(&(temp_mapscr->sflag[k]),f,true))
17223 return qe_invalid;
17224 8272 }
17225
2/2
✓ Branch 0 taken 8272 times.
✓ Branch 1 taken 47 times.
8319 for(int32_t k=0; k<176; ++k)
17226 {
17227
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8272 times.
8272 if(!p_getc(&(temp_mapscr->cset[k]),f,true))
17228 return qe_invalid;
17229 8272 }
17230 47 }
17231
1/2
✓ Branch 0 taken 47 times.
✗ Branch 1 not taken.
47 if(scr_has_flags & SCRHAS_MISC)
17232 {
17233
1/2
✓ Branch 0 taken 47 times.
✗ Branch 1 not taken.
47 if(!p_igetw(&(temp_mapscr->color),f,true))
17234 return qe_invalid;
17235
1/2
✓ Branch 0 taken 47 times.
✗ Branch 1 not taken.
47 if(!p_getc(&(temp_mapscr->csensitive),f,true))
17236 return qe_invalid;
17237
1/2
✓ Branch 0 taken 47 times.
✗ Branch 1 not taken.
47 if(!p_getc(&(temp_mapscr->oceansfx),f,true))
17238 return qe_invalid;
17239
1/2
✓ Branch 0 taken 47 times.
✗ Branch 1 not taken.
47 if(!p_getc(&(temp_mapscr->bosssfx),f,true))
17240 return qe_invalid;
17241
1/2
✓ Branch 0 taken 47 times.
✗ Branch 1 not taken.
47 if(!p_getc(&(temp_mapscr->secretsfx),f,true))
17242 return qe_invalid;
17243
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 47 times.
47 if(!p_getc(&(temp_mapscr->holdupsfx),f,true))
17244 return qe_invalid;
17245
1/2
✓ Branch 0 taken 47 times.
✗ Branch 1 not taken.
47 if(!p_igetw(&(temp_mapscr->timedwarptics),f,true))
17246 return qe_invalid;
17247
1/2
✓ Branch 0 taken 47 times.
✗ Branch 1 not taken.
47 if(!p_igetw(&(temp_mapscr->screen_midi),f,true))
17248 return qe_invalid;
17249
1/2
✓ Branch 0 taken 47 times.
✗ Branch 1 not taken.
47 if(!p_getc(&(temp_mapscr->lens_layer),f,true))
17250 return qe_invalid;
17251 47 }
17252 else
17253 {
17254 temp_mapscr->screen_midi = -1;
17255 temp_mapscr->csensitive = 1;
17256 }
17257 //FFC
17258 47 bool old_ff = version < 25;
17259 47 dword bits = 0;
17260 47 word numffc = 32;
17261
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 25 times.
47 if(old_ff)
17262 {
17263
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 if(!p_igetl(&bits,f,true))
17264 return qe_invalid;
17265 22 }
17266 else
17267 {
17268
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_igetw(&numffc,f,true))
17269 return qe_invalid;
17270 }
17271 byte tempbyte;
17272 word tempw;
17273
4/6
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 44 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
47 static ffcdata nil_ffc;
17274
2/2
✓ Branch 0 taken 47 times.
✓ Branch 1 taken 1013 times.
1060 for(word m = 0; m < numffc; ++m)
17275 {
17276
1/2
✓ Branch 0 taken 1013 times.
✗ Branch 1 not taken.
1013 ffcdata& tempffc = (m < MAXFFCS)
17277 1013 ? temp_mapscr->ffcs[m]
17278 : nil_ffc; //sanity
17279 1013 tempffc.clear();
17280
3/4
✓ Branch 0 taken 704 times.
✓ Branch 1 taken 309 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 704 times.
1013 if(old_ff && !(bits & (1<<m))) continue;
17281
17282
1/2
✓ Branch 0 taken 309 times.
✗ Branch 1 not taken.
309 if(!p_igetw(&tempw,f,true))
17283 return qe_invalid;
17284
3/4
✓ Branch 0 taken 309 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 42 times.
✓ Branch 3 taken 267 times.
309 if(!old_ff && !tempw) //empty ffc, nothing more to load
17285 267 continue;
17286 42 tempffc.setData(tempw);
17287
17288
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 42 times.
42 if(!p_getc(&(tempffc.cset),f,true))
17289 return qe_invalid;
17290
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 42 times.
42 if(!p_igetw(&(tempffc.delay),f,true))
17291 return qe_invalid;
17292
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 42 times.
42 if(!p_igetzf(&(tempffc.x),f,true))
17293 return qe_invalid;
17294
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 42 times.
42 if(!p_igetzf(&(tempffc.y),f,true))
17295 return qe_invalid;
17296
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 42 times.
42 if(!p_igetzf(&(tempffc.vx),f,true))
17297 return qe_invalid;
17298
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 42 times.
42 if(!p_igetzf(&(tempffc.vy),f,true))
17299 return qe_invalid;
17300
1/2
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
42 if(!p_igetzf(&(tempffc.ax),f,true))
17301 return qe_invalid;
17302
1/2
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
42 if(!p_igetzf(&(tempffc.ay),f,true))
17303 return qe_invalid;
17304
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 42 times.
42 if(!p_getc(&(tempffc.link),f,true))
17305 return qe_invalid;
17306
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 42 times.
42 if(version < 24)
17307 {
17308 if(!p_getc(&tempbyte,f,true))
17309 return qe_invalid;
17310 tempffc.hxsz = (tempbyte&0x3F)+1;
17311 tempffc.txsz = (tempbyte>>6)+1;
17312 if(!p_getc(&tempbyte,f,true))
17313 return qe_invalid;
17314 tempffc.hysz = (tempbyte&0x3F)+1;
17315 tempffc.tysz = (tempbyte>>6)+1;
17316 }
17317 else
17318 {
17319
1/2
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
42 if(!p_igetl(&(tempffc.hxsz),f,true))
17320 return qe_invalid;
17321
1/2
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
42 if(!p_igetl(&(tempffc.hysz),f,true))
17322 return qe_invalid;
17323
1/2
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
42 if(!p_getc(&(tempffc.txsz),f,true))
17324 return qe_invalid;
17325
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 42 times.
42 if(!p_getc(&(tempffc.tysz),f,true))
17326 return qe_invalid;
17327 }
17328
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 42 times.
42 if(!p_igetl(&(tempffc.flags),f,true))
17329 return qe_invalid;
17330 42 tempffc.updateSolid();
17331
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 42 times.
42 if(!p_igetw(&(tempffc.script),f,true))
17332 return qe_invalid;
17333
2/2
✓ Branch 0 taken 336 times.
✓ Branch 1 taken 42 times.
378 for(auto q = 0; q < 8; ++q)
17334 {
17335
1/2
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
336 if(!p_igetl(&(tempffc.initd[q]),f,true))
17336 return qe_invalid;
17337 336 }
17338
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 42 times.
42 if(!p_getc(&(tempbyte),f,true))
17339 return qe_invalid;
17340 42 tempffc.inita[0]=tempbyte*10000;
17341
17342
1/2
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
42 if(!p_getc(&(tempbyte),f,true))
17343 return qe_invalid;
17344 42 tempffc.inita[1]=tempbyte*10000;
17345
17346 42 tempffc.initialized = false;
17347 42 }
17348
2/2
✓ Branch 0 taken 5003 times.
✓ Branch 1 taken 47 times.
5050 for(word m = numffc; m < MAXFFCS; ++m)
17349 {
17350 5003 temp_mapscr->ffcs[m].clear();
17351 5003 }
17352 47 temp_mapscr->update_ffc_count(numffc-1);
17353 //END FFC
17354 }
17355 97287 return 0;
17356 98056 }
17357
17358
17359 58 int32_t readmaps(PACKFILE *f, zquestheader *Header, bool keepdata)
17360 {
17361 58 int32_t scr=0;
17362
17363 58 word version=0;
17364 dword dummy;
17365 int32_t screens_to_read;
17366
17367 58 mapscr temp_mapscr;
17368 zcmap temp_map;
17369 word temp_map_count;
17370 dword section_size;
17371
17372
2/6
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 58 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
58 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
17373 {
17374 screens_to_read=MAPSCRS192b136;
17375 }
17376 else
17377 {
17378 58 screens_to_read=MAPSCRS;
17379 }
17380
17381
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(Header->zelda_version > 0x192)
17382 {
17383 //section version info
17384
2/4
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 58 times.
✗ Branch 3 not taken.
58 if(!p_igetw(&version,f,true))
17385 {
17386 return qe_invalid;
17387 }
17388
17389 58 FFCore.quest_format[vMaps] = version;
17390
17391 //al_trace("Maps version %d\n", version);
17392
2/4
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 58 times.
✗ Branch 3 not taken.
58 if(!p_igetw(&dummy,f,true))
17393 {
17394 return qe_invalid;
17395 }
17396
17397 //section size
17398
2/4
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 58 times.
✗ Branch 3 not taken.
58 if(!p_igetl(&section_size,f,true))
17399 {
17400 return qe_invalid;
17401 }
17402
17403 //finally... section data
17404
2/4
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 58 times.
✗ Branch 3 not taken.
58 if(!p_igetw(&temp_map_count,f,true))
17405 {
17406 return 5;
17407 }
17408 58 }
17409 else
17410 {
17411 temp_map_count=map_count;
17412 }
17413
17414
17415
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(keepdata)
17416 {
17417 58 const int32_t _mapsSize = MAPSCRS*temp_map_count;
17418
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 TheMaps.resize(_mapsSize);
17419
17420
2/2
✓ Branch 0 taken 98056 times.
✓ Branch 1 taken 58 times.
98114 for(int32_t i(0); i<_mapsSize; i++)
17421
1/2
✓ Branch 0 taken 98056 times.
✗ Branch 1 not taken.
98056 TheMaps[i].zero_memory();
17422
17423 // Used to be done for each screen
17424
2/2
✓ Branch 0 taken 7424 times.
✓ Branch 1 taken 58 times.
7482 for(int32_t i=0; i<MAXFFCS; i++)
17425 {
17426 7424 ffcScriptData[i].a[0] = 10000;
17427 7424 ffcScriptData[i].a[1] = 10000;
17428 7424 }
17429
17430 58 memset(ZCMaps, 0, sizeof(zcmap)*MAXMAPS2);
17431 58 }
17432
17433
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 temp_mapscr.zero_memory();
17434
17435 58 memset(&temp_map, 0, sizeof(zcmap));
17436 58 temp_map.scrResWidth = 256;
17437 58 temp_map.scrResHeight = 224;
17438 58 temp_map.tileWidth = 16;
17439 58 temp_map.tileHeight = 11;
17440 58 temp_map.viewWidth = 256;
17441 58 temp_map.viewHeight = 176;
17442 58 temp_map.viewX = 0;
17443 58 temp_map.viewY = 64;
17444 58 temp_map.subaWidth = 256;
17445 58 temp_map.subaHeight = 168;
17446 58 temp_map.subaTrans = false;
17447 58 temp_map.subpWidth = 256;
17448 58 temp_map.subpHeight = 56;
17449 58 temp_map.subpTrans = false;
17450
4/4
✓ Branch 0 taken 58 times.
✓ Branch 1 taken 721 times.
✓ Branch 2 taken 58 times.
✓ Branch 3 taken 721 times.
779 for(int32_t i=0; i<temp_map_count && i<MAXMAPS2; i++)
17451 {
17452
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 721 times.
721 if(keepdata==true) //!TODO Trim fully
17453 {
17454 721 memcpy(&ZCMaps[i], &temp_map, sizeof(zcmap));
17455 721 }
17456 721 byte valid=1;
17457
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 715 times.
721 if(version > 22)
17458 {
17459
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if(!p_getc(&valid,f,true))
17460 return qe_invalid;
17461 6 }
17462
2/2
✓ Branch 0 taken 98056 times.
✓ Branch 1 taken 721 times.
98777 for(int32_t j=0; j<screens_to_read; j++)
17463 {
17464 98056 scr=i*MAPSCRS+j;
17465
1/2
✓ Branch 0 taken 98056 times.
✗ Branch 1 not taken.
98056 clear_screen(&temp_mapscr);
17466
1/2
✓ Branch 0 taken 98056 times.
✗ Branch 1 not taken.
98056 if(valid)
17467
1/2
✓ Branch 0 taken 98056 times.
✗ Branch 1 not taken.
98056 readmapscreen(f, Header, &temp_mapscr, &temp_map, version);
17468
17469
1/2
✓ Branch 0 taken 98056 times.
✗ Branch 1 not taken.
98056 if(keepdata==true)
17470 {
17471
1/2
✓ Branch 0 taken 98056 times.
✗ Branch 1 not taken.
98056 TheMaps[scr] = temp_mapscr;
17472 98056 }
17473 98056 }
17474
17475
1/2
✓ Branch 0 taken 721 times.
✗ Branch 1 not taken.
721 if(keepdata==true)
17476 {
17477
2/6
✓ Branch 0 taken 721 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 721 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
721 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
17478 {
17479 int32_t index = (i*MAPSCRS+132);
17480
17481 TheMaps[index]=TheMaps[index-1];
17482
17483 MEMCPY_ARR(TheMaps[i*MAPSCRS+132].data, TheMaps[i*MAPSCRS+131].data);
17484 MEMCPY_ARR(TheMaps[i*MAPSCRS+132].sflag, TheMaps[i*MAPSCRS+131].sflag);
17485 MEMCPY_ARR(TheMaps[i*MAPSCRS+132].cset, TheMaps[i*MAPSCRS+131].cset);
17486
17487 for(int32_t j=133; j<MAPSCRS; j++)
17488 {
17489 scr=i*MAPSCRS+j;
17490
17491 TheMaps[scr].zero_memory();
17492 TheMaps[scr].valid = mVERSION;
17493 TheMaps[scr].screen_midi = -1;
17494 TheMaps[scr].csensitive = 1;
17495 }
17496 }
17497
17498
2/6
✓ Branch 0 taken 721 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 721 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
721 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
17499 {
17500 for(int32_t j=0; j<MAPSCRS; j++)
17501 {
17502 scr=i*MAPSCRS+j;
17503 TheMaps[scr].door_combo_set=MakeDoors(i, j);
17504
17505 for(int32_t k=0; k<128; k++)
17506 {
17507 TheMaps[scr].secretcset[k]=tcmbcset2(i, TheMaps[scr].secretcombo[k]);
17508 TheMaps[scr].secretflag[k]=tcmbflag2(i, TheMaps[scr].secretcombo[k]);
17509 TheMaps[scr].secretcombo[k]=tcmbdat2(i, j, TheMaps[scr].secretcombo[k]);
17510 }
17511 }
17512 }
17513 721 }
17514 721 }
17515
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 if(keepdata)
17516 {
17517 58 map_count = temp_map_count;
17518 58 }
17519
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 clear_screen(&temp_mapscr);
17520 58 return 0;
17521 58 }
17522
17523
17524 55 int32_t readcombos_old(word section_version, PACKFILE *f, zquestheader *, word version, word build, word start_combo, word max_combos, bool keepdata)
17525 {
17526 55 reset_combo_animations();
17527 55 reset_combo_animations2();
17528
17529 55 init_combo_classes();
17530
17531 // combos
17532 55 word combos_used=0;
17533 int32_t dummy;
17534 byte padding;
17535 55 newcombo temp_combo;
17536 //word section_cversion=0;
17537
17538
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
55 if(keepdata==true)
17539 {
17540
2/2
✓ Branch 0 taken 3590400 times.
✓ Branch 1 taken 55 times.
3590455 for(int32_t q = start_combo; q < start_combo+max_combos; ++q)
17541 3590400 combobuf[q].clear();
17542 55 }
17543
17544 // if(version > 0x192)
17545 // {
17546 // //section version info
17547 // if(!p_igetw(&section_version,f,true))
17548 // {
17549 // return qe_invalid;
17550 // }
17551
17552 // FFCore.quest_format[vCombos] = section_version;
17553
17554 // //al_trace("Combos version %d\n", section_version);
17555 // if(!p_igetw(&section_cversion,f,true))
17556 // {
17557 // return qe_invalid;
17558 // }
17559
17560 // //section size
17561 // if(!p_igetl(&dummy,f,true))
17562 // {
17563 // return qe_invalid;
17564 // }
17565 // }
17566
17567
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
55 if(version < 0x174)
17568 {
17569 combos_used=1024;
17570 }
17571
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
55 else if(version < 0x191)
17572 {
17573 combos_used=2048;
17574 }
17575 else
17576 {
17577
1/2
✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
55 if(!p_igetw(&combos_used,f,true))
17578 {
17579 return qe_invalid;
17580 }
17581 }
17582
17583 //finally... section data
17584
2/2
✓ Branch 0 taken 146454 times.
✓ Branch 1 taken 55 times.
146509 for(int32_t i=0; i<combos_used; i++)
17585 {
17586 146454 temp_combo.clear();
17587
17588
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 146454 times.
146454 if ( section_version >= 11 )
17589 {
17590 if(!p_igetl(&temp_combo.tile,f,true))
17591 {
17592 return qe_invalid;
17593 }
17594 }
17595 else
17596 {
17597
1/2
✓ Branch 0 taken 146454 times.
✗ Branch 1 not taken.
146454 if(!p_igetw(&temp_combo.tile,f,true))
17598 {
17599 return qe_invalid;
17600 }
17601 }
17602 146454 temp_combo.o_tile = temp_combo.tile;
17603
1/2
✓ Branch 0 taken 146454 times.
✗ Branch 1 not taken.
146454 if(!p_getc(&temp_combo.flip,f,true))
17604 {
17605 return qe_invalid;
17606 }
17607
17608
1/2
✓ Branch 0 taken 146454 times.
✗ Branch 1 not taken.
146454 if(!p_getc(&temp_combo.walk,f,true))
17609 {
17610 return qe_invalid;
17611 }
17612
17613
1/2
✓ Branch 0 taken 146454 times.
✗ Branch 1 not taken.
146454 if(!p_getc(&temp_combo.type,f,true))
17614 {
17615 return qe_invalid;
17616 }
17617
17618
1/2
✓ Branch 0 taken 146454 times.
✗ Branch 1 not taken.
146454 if(!p_getc(&temp_combo.csets,f,true))
17619 {
17620 return qe_invalid;
17621 }
17622
17623
1/2
✓ Branch 0 taken 146454 times.
✗ Branch 1 not taken.
146454 if(version < 0x193)
17624 {
17625 if(!p_getc(&padding,f,true))
17626 {
17627 return qe_invalid;
17628 }
17629
17630 if(!p_getc(&padding,f,true))
17631 {
17632 return qe_invalid;
17633 }
17634
17635 if(version < 0x192)
17636 {
17637 if(version == 0x191)
17638 {
17639 for(int32_t tmpcounter=0; tmpcounter<16; tmpcounter++)
17640 {
17641 if(!p_getc(&padding,f,true))
17642 {
17643 return qe_invalid;
17644 }
17645 }
17646 }
17647
17648 if(keepdata==true)
17649 {
17650 memcpy(&combobuf[i], &temp_combo, sizeof(temp_combo));
17651 }
17652
17653 continue;
17654 }
17655 }
17656
17657
1/2
✓ Branch 0 taken 146454 times.
✗ Branch 1 not taken.
146454 if(!p_getc(&temp_combo.frames,f,true))
17658 {
17659 return qe_invalid;
17660 }
17661
17662
1/2
✓ Branch 0 taken 146454 times.
✗ Branch 1 not taken.
146454 if(!p_getc(&temp_combo.speed,f,true))
17663 {
17664 return qe_invalid;
17665 }
17666
17667
1/2
✓ Branch 0 taken 146454 times.
✗ Branch 1 not taken.
146454 if(!p_igetw(&temp_combo.nextcombo,f,true))
17668 {
17669 return qe_invalid;
17670 }
17671
17672
1/2
✓ Branch 0 taken 146454 times.
✗ Branch 1 not taken.
146454 if(!p_getc(&temp_combo.nextcset,f,true))
17673 {
17674 return qe_invalid;
17675 }
17676
17677 //Base flag
17678
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 146454 times.
146454 if(section_version>=3)
17679 {
17680
1/2
✓ Branch 0 taken 146454 times.
✗ Branch 1 not taken.
146454 if(!p_getc(&temp_combo.flag,f,true))
17681 {
17682 return qe_invalid;
17683 }
17684 146454 }
17685
17686
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 146454 times.
146454 if(section_version>=4)
17687 {
17688
1/2
✓ Branch 0 taken 146454 times.
✗ Branch 1 not taken.
146454 if(!p_getc(&temp_combo.skipanim,f,true))
17689 {
17690 return qe_invalid;
17691 }
17692
17693
1/2
✓ Branch 0 taken 146454 times.
✗ Branch 1 not taken.
146454 if(!p_igetw(&temp_combo.nexttimer,f,true))
17694 {
17695 return qe_invalid;
17696 }
17697 146454 }
17698
17699
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 146454 times.
146454 if(section_version>=5)
17700 {
17701
1/2
✓ Branch 0 taken 146454 times.
✗ Branch 1 not taken.
146454 if(!p_getc(&temp_combo.skipanimy,f,true))
17702 {
17703 return qe_invalid;
17704 }
17705 146454 }
17706
17707
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 146454 times.
146454 if(section_version>=6)
17708 {
17709
1/2
✓ Branch 0 taken 146454 times.
✗ Branch 1 not taken.
146454 if(!p_getc(&temp_combo.animflags,f,true))
17710 {
17711 return qe_invalid;
17712 }
17713
17714
1/2
✓ Branch 0 taken 146454 times.
✗ Branch 1 not taken.
146454 if(section_version == 6)
17715 temp_combo.animflags = temp_combo.animflags ? AF_FRESH : 0;
17716 146454 }
17717
17718
1/2
✓ Branch 0 taken 146454 times.
✗ Branch 1 not taken.
146454 if(section_version>=8) //combo Attributes[4] and userflags.
17719 {
17720 for ( int32_t q = 0; q < NUM_COMBO_ATTRIBUTES; q++ )
17721 {
17722 if(!p_igetl(&temp_combo.attributes[q],f,true))
17723 {
17724 return qe_invalid;
17725 }
17726 }
17727 if(!p_igetl(&temp_combo.usrflags,f,true))
17728 {
17729 return qe_invalid;
17730 }
17731 if(section_version >= 20)
17732 {
17733 if(!p_igetw(&temp_combo.genflags,f,true))
17734 {
17735 return qe_invalid;
17736 }
17737 }
17738 else
17739 {
17740 temp_combo.genflags = 0;
17741 switch(temp_combo.type)
17742 {
17743 case cPUSH_WAIT: case cPUSH_HEAVY:
17744 case cPUSH_HW: case cL_STATUE:
17745 case cR_STATUE: case cPUSH_HEAVY2:
17746 case cPUSH_HW2: case cPOUND:
17747 case cC_STATUE: case cMIRROR:
17748 case cMIRRORSLASH: case cMIRRORBACKSLASH:
17749 case cMAGICPRISM: case cMAGICPRISM4:
17750 case cMAGICSPONGE: case cEYEBALL_A:
17751 case cEYEBALL_B: case cEYEBALL_4:
17752 case cBUSH: case cFLOWERS:
17753 case cLOCKBLOCK: case cLOCKBLOCK2:
17754 case cBOSSLOCKBLOCK: case cBOSSLOCKBLOCK2:
17755 case cCHEST: case cCHEST2:
17756 case cLOCKEDCHEST: case cLOCKEDCHEST2:
17757 case cBOSSCHEST: case cBOSSCHEST2:
17758 case cBUSHNEXT: case cBUSHTOUCHY:
17759 case cFLOWERSTOUCHY: case cBUSHNEXTTOUCHY:
17760 case cSIGNPOST: case cCSWITCHBLOCK:
17761 case cTORCH: case cTRIGGERGENERIC:
17762 if(temp_combo.usrflags & cflag16)
17763 {
17764 temp_combo.genflags |= cflag1;
17765 temp_combo.usrflags &= ~cflag16;
17766 }
17767 break; }
17768 }
17769 }
17770
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 146454 times.
146454 if(section_version>=10) //combo trigger flags
17771 {
17772 for ( int32_t q = 0; q < 3; q++ )
17773 {
17774 if(!p_igetl(&temp_combo.triggerflags[q],f,true))
17775 {
17776 return qe_invalid;
17777 }
17778 }
17779 }
17780
1/2
✓ Branch 0 taken 146454 times.
✗ Branch 1 not taken.
146454 else if(section_version==9) //combo trigger flags, V9 only had two indices of triggerflags[]
17781 {
17782 for ( int32_t q = 0; q < 2; q++ )
17783 {
17784 if(!p_igetl(&temp_combo.triggerflags[q],f,true))
17785 {
17786 return qe_invalid;
17787 }
17788 }
17789 }
17790
1/2
✓ Branch 0 taken 146454 times.
✗ Branch 1 not taken.
146454 if(section_version >= 9)
17791 {
17792 if(!p_igetl(&temp_combo.triggerlevel,f,true))
17793 {
17794 return qe_invalid;
17795 }
17796 }
17797
1/2
✓ Branch 0 taken 146454 times.
✗ Branch 1 not taken.
146454 if(section_version >= 22)
17798 {
17799 if(!p_getc(&temp_combo.triggerbtn,f,true))
17800 {
17801 return qe_invalid;
17802 }
17803 }
17804
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 146454 times.
146454 if(section_version < 23)
17805 {
17806
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 146454 times.
146454 switch(temp_combo.type) //combotriggerCMBTYPEFX now required for combotype-specific effects
17807 {
17808 case cSCRIPT1: case cSCRIPT2: case cSCRIPT3: case cSCRIPT4: case cSCRIPT5:
17809 case cSCRIPT6: case cSCRIPT7: case cSCRIPT8: case cSCRIPT9: case cSCRIPT10:
17810 case cTRIGGERGENERIC: case cCSWITCH:
17811 temp_combo.triggerflags[0] |= combotriggerCMBTYPEFX;
17812 }
17813 146454 }
17814
1/2
✓ Branch 0 taken 146454 times.
✗ Branch 1 not taken.
146454 if(section_version >= 24)
17815 {
17816 if(!p_getc(&temp_combo.triggeritem,f,true))
17817 {
17818 return qe_invalid;
17819 }
17820 if(!p_getc(&temp_combo.trigtimer,f,true))
17821 {
17822 return qe_invalid;
17823 }
17824 }
17825
1/2
✓ Branch 0 taken 146454 times.
✗ Branch 1 not taken.
146454 if(section_version >= 25)
17826 {
17827 if(!p_getc(&temp_combo.trigsfx,f,true))
17828 {
17829 return qe_invalid;
17830 }
17831 }
17832
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 146454 times.
146454 if(section_version >= 27)
17833 {
17834 if(!p_igetl(&temp_combo.trigchange,f,true))
17835 {
17836 return qe_invalid;
17837 }
17838 }
17839 else
17840 {
17841
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 146454 times.
146454 if(temp_combo.triggerflags[0] & 0x00040000) //'next'
17842 temp_combo.trigchange = 1;
17843
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 146454 times.
146454 else if(temp_combo.triggerflags[0] & 0x00080000) //'prev'
17844 temp_combo.trigchange = -1;
17845 146454 else temp_combo.trigchange = 0;
17846 146454 temp_combo.triggerflags[0] &= ~(0x00040000|0x00080000);
17847 }
17848
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 146454 times.
146454 if(section_version >= 29)
17849 {
17850 if(!p_igetw(&temp_combo.trigprox,f,true))
17851 {
17852 return qe_invalid;
17853 }
17854 if(!p_getc(&temp_combo.trigctr,f,true))
17855 {
17856 return qe_invalid;
17857 }
17858 if(!p_igetl(&temp_combo.trigctramnt,f,true))
17859 {
17860 return qe_invalid;
17861 }
17862 }
17863 else
17864 {
17865 146454 temp_combo.trigprox = 0;
17866 146454 temp_combo.trigctr = 0;
17867 146454 temp_combo.trigctramnt = 0;
17868 }
17869
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 146454 times.
146454 if(section_version >= 30)
17870 {
17871 if(!p_getc(&temp_combo.triglbeam,f,true))
17872 {
17873 return qe_invalid;
17874 }
17875 }
17876 146454 else temp_combo.triglbeam = 0;
17877
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 146454 times.
146454 if(section_version >= 31)
17878 {
17879 if(!p_getc(&temp_combo.trigcschange,f,true))
17880 {
17881 return qe_invalid;
17882 }
17883 if(!p_igetw(&temp_combo.spawnitem,f,true))
17884 {
17885 return qe_invalid;
17886 }
17887 if(!p_igetw(&temp_combo.spawnenemy,f,true))
17888 {
17889 return qe_invalid;
17890 }
17891 if(!p_getc(&temp_combo.exstate,f,true))
17892 {
17893 return qe_invalid;
17894 }
17895 if(!p_igetl(&temp_combo.spawnip,f,true))
17896 {
17897 return qe_invalid;
17898 }
17899 if(!p_getc(&temp_combo.trigcopycat,f,true))
17900 {
17901 return qe_invalid;
17902 }
17903 }
17904 else
17905 {
17906 146454 temp_combo.trigcschange = 0;
17907 146454 temp_combo.spawnitem = 0;
17908 146454 temp_combo.spawnenemy = 0;
17909 146454 temp_combo.exstate = -1;
17910 146454 temp_combo.spawnip = 0;
17911 146454 temp_combo.trigcopycat = 0;
17912 }
17913
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 146454 times.
146454 if(section_version >= 32)
17914 {
17915 if(!p_getc(&temp_combo.trigcooldown,f,true))
17916 {
17917 return qe_invalid;
17918 }
17919 }
17920 else
17921 {
17922 146454 temp_combo.trigcooldown = 0;
17923 }
17924
17925
1/2
✓ Branch 0 taken 146454 times.
✗ Branch 1 not taken.
146454 if(section_version>=12) //combo label
17926 {
17927 for ( int32_t q = 0; q < 11; q++ )
17928 {
17929 if(!p_getc(&temp_combo.label[q],f,true))
17930 {
17931 return qe_invalid;
17932 }
17933 }
17934 }
17935
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 146454 times.
146454 if(section_version<12) //combo label
17936 {
17937
2/2
✓ Branch 0 taken 1610994 times.
✓ Branch 1 taken 146454 times.
1757448 for ( int32_t q = 0; q < 11; q++ )
17938 {
17939 1610994 temp_combo.label[q] = 0;
17940 1610994 }
17941 146454 }
17942 //al_trace("Read combo label\n");
17943
1/2
✓ Branch 0 taken 146454 times.
✗ Branch 1 not taken.
146454 if(section_version>=13) //attribytes[4]
17944 {
17945 for ( int32_t q = 0; q < 4; q++ ) //Bad Zoria, don't mix constants with hardcodes
17946 {
17947 if(!p_getc(&temp_combo.attribytes[q],f,true))
17948 {
17949 return qe_invalid;
17950 }
17951 }
17952
17953 }
17954 //al_trace("Read combo attribytes\n");
17955
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 146454 times.
146454 if( section_version < 13 )
17956 {
17957
2/2
✓ Branch 0 taken 585816 times.
✓ Branch 1 taken 146454 times.
732270 for ( int32_t q = 0; q < NUM_COMBO_ATTRIBUTES; q++ )
17958 {
17959 585816 temp_combo.attribytes[q] = 0;
17960 585816 }
17961
17962 146454 }
17963 /* HIGHLY UNORTHODOX UPDATING THING, by Deedee
17964 * This fixes a poor implementation of a ->next flag bug thing.
17965 * Zoria didn't bump up the versions as liberally as he should have, but thankfully
17966 * there was a version bump a few weeks before a change that broke stuff.
17967 */
17968
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 146454 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
146454 if (section_version >= 13 && section_version < 21)
17969 {
17970 set_bit(quest_rules,qr_BUGGY_BUGGY_SLASH_TRIGGERS,1);
17971 }
17972 //combo scripts
17973
1/2
✓ Branch 0 taken 146454 times.
✗ Branch 1 not taken.
146454 if(section_version>=14)
17974 {
17975 if(!p_igetw(&temp_combo.script,f,true)) return qe_invalid;
17976 for ( int32_t q = 0; q < 2; q++ )
17977 {
17978 if(!p_igetl(&temp_combo.initd[q],f,true))
17979 {
17980 return qe_invalid;
17981 }
17982 }
17983
17984 }
17985
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 146454 times.
146454 if(section_version<14)
17986 {
17987 146454 temp_combo.script = 0;
17988
2/2
✓ Branch 0 taken 292908 times.
✓ Branch 1 taken 146454 times.
439362 for ( int32_t q = 0; q < 2; q++ )
17989 {
17990 292908 temp_combo.initd[q] = 0;
17991 292908 }
17992 146454 }
17993 //al_trace("Read combo script data\n");
17994
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 146454 times.
146454 if(section_version>=15)
17995 {
17996 if(!p_igetl(&temp_combo.o_tile,f,true)) return qe_invalid;
17997 if(!temp_combo.o_tile) temp_combo.o_tile = temp_combo.tile;
17998 if(!p_getc(&temp_combo.cur_frame,f,true)) return qe_invalid;
17999 if(!p_getc(&temp_combo.aclk,f,true)) return qe_invalid;
18000 }
18001 else
18002 {
18003 146454 temp_combo.o_tile = temp_combo.tile;
18004 146454 temp_combo.cur_frame = 0;
18005 146454 temp_combo.aclk = 0;
18006 }
18007
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 146454 times.
146454 if(section_version>=17) //attribytes[4]
18008 {
18009 for ( int32_t q = 4; q < 8; q++ ) //bump up attribytes...
18010 {
18011 if(!p_getc(&temp_combo.attribytes[q],f,true))
18012 {
18013 return qe_invalid;
18014 }
18015 }
18016 for ( int32_t q = 0; q < 8; q++ ) //...and add attrishorts
18017 {
18018 if(!p_igetw(&temp_combo.attrishorts[q],f,true))
18019 {
18020 return qe_invalid;
18021 }
18022 }
18023
18024 }
18025 else
18026 {
18027
2/2
✓ Branch 0 taken 585816 times.
✓ Branch 1 taken 146454 times.
732270 for ( int32_t q = 4; q < 8; q++ ) //bump up attribytes...
18028 {
18029 585816 temp_combo.attribytes[q] = 0;
18030 585816 }
18031
2/2
✓ Branch 0 taken 1171632 times.
✓ Branch 1 taken 146454 times.
1318086 for ( int32_t q = 0; q < 8; q++ ) //...and add attrishorts
18032 {
18033 1171632 temp_combo.attrishorts[q] = 0;
18034 1171632 }
18035 }
18036
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 146454 times.
146454 if(section_version<18) //upper bits for .walk
18037 {
18038 146454 temp_combo.walk |= 0xF0; //All on by default for old quests -E
18039 146454 }
18040
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 146454 times.
146454 if(section_version < 19)
18041 {
18042
2/2
✓ Branch 0 taken 585816 times.
✓ Branch 1 taken 146454 times.
732270 for(int32_t q = 0; q < 4; ++q)
18043 {
18044 585816 temp_combo.attributes[q] *= 10000L;
18045 585816 }
18046 146454 }
18047
18048
1/2
✓ Branch 0 taken 146454 times.
✗ Branch 1 not taken.
146454 if(version < 0x193)
18049 {
18050 for(int32_t q=0; q<11; q++)
18051 {
18052 if(!p_getc(&dummy,f,true))
18053 {
18054 return qe_invalid;
18055 }
18056 }
18057 }
18058
18059 //Goriya tiles were flipped around in 2.11 build 7. Compensate for the flip here. -DD
18060
2/6
✓ Branch 0 taken 146454 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 146454 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
146454 if((version < 0x211)||((version == 0x211)&&(build<7)))
18061 {
18062 if(!get_bit(quest_rules,qr_NEWENEMYTILES))
18063 {
18064 switch(temp_combo.tile)
18065 {
18066 case 130:
18067 temp_combo.tile = 132;
18068 break;
18069
18070 case 131:
18071 temp_combo.tile = 133;
18072 break;
18073
18074 case 132:
18075 temp_combo.tile = 130;
18076 break;
18077
18078 case 133:
18079 temp_combo.tile = 131;
18080 break;
18081 }
18082 }
18083 }
18084
18085
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 146454 times.
146454 if(section_version < 25)
18086 {
18087
2/2
✓ Branch 0 taken 1157 times.
✓ Branch 1 taken 145297 times.
146454 switch(temp_combo.type)
18088 {
18089 case cLOCKBLOCK: case cBOSSLOCKBLOCK:
18090
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1157 times.
1157 if(!(temp_combo.usrflags & cflag3))
18091 1157 temp_combo.attribytes[3] = WAV_DOOR;
18092 1157 temp_combo.usrflags &= ~cflag3;
18093 1157 break;
18094 }
18095 146454 }
18096
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 146454 times.
146454 if(section_version < 26)
18097 {
18098
2/2
✓ Branch 0 taken 146106 times.
✓ Branch 1 taken 348 times.
146454 if(temp_combo.type == cARMOS)
18099 {
18100
1/2
✓ Branch 0 taken 348 times.
✗ Branch 1 not taken.
348 if(temp_combo.usrflags & cflag1)
18101 temp_combo.usrflags |= cflag3;
18102 348 }
18103 146454 }
18104
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 146454 times.
146454 if(section_version < 28)
18105 {
18106
2/2
✓ Branch 0 taken 585 times.
✓ Branch 1 taken 145869 times.
146454 switch(temp_combo.type)
18107 {
18108 case cLOCKBLOCK: case cLOCKEDCHEST:
18109
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 585 times.
585 if(temp_combo.usrflags & cflag7)
18110 temp_combo.usrflags |= cflag8;
18111 585 else temp_combo.usrflags &= ~cflag8;
18112 585 temp_combo.usrflags &= ~cflag7;
18113 585 break;
18114 }
18115
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 146454 times.
146454 switch(temp_combo.type)
18116 {
18117 case cCHEST: case cLOCKEDCHEST: case cBOSSCHEST:
18118 temp_combo.attrishorts[2] = -1;
18119 temp_combo.usrflags |= cflag7;
18120 break;
18121 }
18122 146454 }
18123
18124
2/4
✓ Branch 0 taken 146454 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 146454 times.
146454 if(keepdata==true && i>=start_combo)
18125 {
18126 146454 memcpy(&combobuf[i], &temp_combo, sizeof(temp_combo));
18127 146454 }
18128 146454 }
18129
18130
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
55 if(keepdata==true)
18131 {
18132
2/6
✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 55 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
55 if((version < 0x192)|| ((version == 0x192)&&(build<185)))
18133 {
18134 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
18135 {
18136 if(combobuf[tmpcounter].type==cHOOKSHOTONLY)
18137 {
18138 combobuf[tmpcounter].type=cLADDERHOOKSHOT;
18139 }
18140 }
18141 }
18142
18143 //June 3 2012; ladder only is broken in 2.10 and allows the hookshot also. -Gleeok
18144
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
55 if(version == 0x210 && !is_zquest())
18145 {
18146 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
18147 if(combobuf[tmpcounter].type == cLADDERONLY)
18148 combobuf[tmpcounter].type = cLADDERHOOKSHOT;
18149 }
18150
18151
1/2
✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
55 if(section_version<7)
18152 {
18153 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
18154 {
18155 switch(combobuf[tmpcounter].type)
18156 {
18157 case cSLASH:
18158 combobuf[tmpcounter].type=cSLASHTOUCHY;
18159 break;
18160
18161 case cSLASHITEM:
18162 combobuf[tmpcounter].type=cSLASHITEMTOUCHY;
18163 break;
18164
18165 case cBUSH:
18166 combobuf[tmpcounter].type=cBUSHTOUCHY;
18167 break;
18168
18169 case cFLOWERS:
18170 combobuf[tmpcounter].type=cFLOWERSTOUCHY;
18171 break;
18172
18173 case cTALLGRASS:
18174 combobuf[tmpcounter].type=cTALLGRASSTOUCHY;
18175 break;
18176
18177 case cSLASHNEXT:
18178 combobuf[tmpcounter].type=cSLASHNEXTTOUCHY;
18179 break;
18180
18181 case cSLASHNEXTITEM:
18182 combobuf[tmpcounter].type=cSLASHNEXTITEMTOUCHY;
18183 break;
18184
18185 case cBUSHNEXT:
18186 combobuf[tmpcounter].type=cBUSHNEXTTOUCHY;
18187 break;
18188 }
18189 }
18190 }
18191
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
55 if (section_version < 16)
18192 {
18193
2/2
✓ Branch 0 taken 3590400 times.
✓ Branch 1 taken 55 times.
3590455 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
18194 {
18195
2/2
✓ Branch 0 taken 3587515 times.
✓ Branch 1 taken 2885 times.
3590400 if (combobuf[tmpcounter].type == cWATER)
18196 {
18197 2885 combobuf[tmpcounter].attributes[0] = 40000L;
18198 2885 }
18199 3590400 }
18200 55 }
18201
1/2
✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
55 if(!get_bit(quest_rules,qr_ALLOW_EDITING_COMBO_0))
18202 {
18203 combobuf[0].walk = 0xF0;
18204 combobuf[0].type = 0;
18205 combobuf[0].flag = 0;
18206 }
18207 55 }
18208
18209 //Now for the new combo alias reset
18210
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
55 if(section_version<2 && keepdata)
18211 {
18212 for(int32_t j=0; j<MAXCOMBOALIASES; j++)
18213 {
18214 combo_aliases[j].width = 0;
18215 combo_aliases[j].height = 0;
18216 combo_aliases[j].layermask = 0;
18217
18218 if(combo_aliases[j].combos != NULL)
18219 {
18220 delete[] combo_aliases[j].combos;
18221 }
18222
18223 if(combo_aliases[j].csets != NULL)
18224 {
18225 delete[] combo_aliases[j].csets;
18226 }
18227
18228 combo_aliases[j].combos = new word[1];
18229 combo_aliases[j].csets = new byte[1];
18230 combo_aliases[j].combos[0] = 0;
18231 combo_aliases[j].csets[0] = 0;
18232 }
18233 }
18234
18235
18236 55 setup_combo_animations();
18237 55 setup_combo_animations2();
18238 55 return 0;
18239 55 }
18240 15372 int32_t readcombo_loop(PACKFILE* f, word s_version, newcombo& temp_combo)
18241 {
18242 byte combo_has_flags;
18243
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15372 times.
15372 if(!p_getc(&combo_has_flags,f,true))
18244 return qe_invalid;
18245
18246 15372 temp_combo.clear();
18247
2/2
✓ Branch 0 taken 10649 times.
✓ Branch 1 taken 4723 times.
15372 if(combo_has_flags)
18248 {
18249
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4723 times.
4723 if(combo_has_flags&CHAS_GENERAL)
18250 {
18251
1/2
✓ Branch 0 taken 4723 times.
✗ Branch 1 not taken.
4723 if(!p_igetl(&temp_combo.tile,f,true))
18252 {
18253 return qe_invalid;
18254 }
18255 4723 temp_combo.o_tile = temp_combo.tile;
18256
18257
1/2
✓ Branch 0 taken 4723 times.
✗ Branch 1 not taken.
4723 if(!p_getc(&temp_combo.flip,f,true))
18258 {
18259 return qe_invalid;
18260 }
18261
18262
1/2
✓ Branch 0 taken 4723 times.
✗ Branch 1 not taken.
4723 if(!p_getc(&temp_combo.walk,f,true))
18263 {
18264 return qe_invalid;
18265 }
18266
18267
1/2
✓ Branch 0 taken 4723 times.
✗ Branch 1 not taken.
4723 if(!p_getc(&temp_combo.type,f,true))
18268 {
18269 return qe_invalid;
18270 }
18271
18272
1/2
✓ Branch 0 taken 4723 times.
✗ Branch 1 not taken.
4723 if(!p_getc(&temp_combo.flag,f,true))
18273 {
18274 return qe_invalid;
18275 }
18276
18277
1/2
✓ Branch 0 taken 4723 times.
✗ Branch 1 not taken.
4723 if(!p_getc(&temp_combo.csets,f,true))
18278 {
18279 return qe_invalid;
18280 }
18281 4723 }
18282
2/2
✓ Branch 0 taken 4722 times.
✓ Branch 1 taken 1 times.
4723 if(combo_has_flags&CHAS_SCRIPT)
18283 {
18284
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 1 times.
12 for ( int32_t q = 0; q < 11; q++ )
18285 {
18286
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(!p_getc(&temp_combo.label[q],f,true))
18287 {
18288 return qe_invalid;
18289 }
18290 11 }
18291
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!p_igetw(&temp_combo.script,f,true)) return qe_invalid;
18292
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1 times.
3 for ( int32_t q = 0; q < 2; q++ )
18293 {
18294
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(!p_igetl(&temp_combo.initd[q],f,true))
18295 {
18296 return qe_invalid;
18297 }
18298 2 }
18299 1 }
18300
2/2
✓ Branch 0 taken 3991 times.
✓ Branch 1 taken 732 times.
4723 if(combo_has_flags&CHAS_ANIM)
18301 {
18302
1/2
✓ Branch 0 taken 732 times.
✗ Branch 1 not taken.
732 if(!p_getc(&temp_combo.frames,f,true))
18303 {
18304 return qe_invalid;
18305 }
18306
18307
1/2
✓ Branch 0 taken 732 times.
✗ Branch 1 not taken.
732 if(!p_getc(&temp_combo.speed,f,true))
18308 {
18309 return qe_invalid;
18310 }
18311
18312
1/2
✓ Branch 0 taken 732 times.
✗ Branch 1 not taken.
732 if(!p_igetw(&temp_combo.nextcombo,f,true))
18313 {
18314 return qe_invalid;
18315 }
18316
18317
1/2
✓ Branch 0 taken 732 times.
✗ Branch 1 not taken.
732 if(!p_getc(&temp_combo.nextcset,f,true))
18318 {
18319 return qe_invalid;
18320 }
18321
18322
1/2
✓ Branch 0 taken 732 times.
✗ Branch 1 not taken.
732 if(!p_getc(&temp_combo.skipanim,f,true))
18323 {
18324 return qe_invalid;
18325 }
18326
18327
1/2
✓ Branch 0 taken 732 times.
✗ Branch 1 not taken.
732 if(!p_getc(&temp_combo.skipanimy,f,true))
18328 {
18329 return qe_invalid;
18330 }
18331
18332
1/2
✓ Branch 0 taken 732 times.
✗ Branch 1 not taken.
732 if(!p_getc(&temp_combo.animflags,f,true))
18333 {
18334 return qe_invalid;
18335 }
18336 732 }
18337
2/2
✓ Branch 0 taken 4099 times.
✓ Branch 1 taken 624 times.
4723 if(combo_has_flags&CHAS_ATTRIB)
18338 {
18339
2/2
✓ Branch 0 taken 2496 times.
✓ Branch 1 taken 624 times.
3120 for ( int32_t q = 0; q < 4; q++ )
18340 {
18341
1/2
✓ Branch 0 taken 2496 times.
✗ Branch 1 not taken.
2496 if(!p_igetl(&temp_combo.attributes[q],f,true))
18342 {
18343 return qe_invalid;
18344 }
18345 2496 }
18346
2/2
✓ Branch 0 taken 4992 times.
✓ Branch 1 taken 624 times.
5616 for ( int32_t q = 0; q < 8; q++ )
18347 {
18348
1/2
✓ Branch 0 taken 4992 times.
✗ Branch 1 not taken.
4992 if(!p_getc(&temp_combo.attribytes[q],f,true))
18349 {
18350 return qe_invalid;
18351 }
18352 4992 }
18353
2/2
✓ Branch 0 taken 4992 times.
✓ Branch 1 taken 624 times.
5616 for ( int32_t q = 0; q < 8; q++ )
18354 {
18355
1/2
✓ Branch 0 taken 4992 times.
✗ Branch 1 not taken.
4992 if(!p_igetw(&temp_combo.attrishorts[q],f,true))
18356 {
18357 return qe_invalid;
18358 }
18359 4992 }
18360 624 }
18361
2/2
✓ Branch 0 taken 4529 times.
✓ Branch 1 taken 194 times.
4723 if(combo_has_flags&CHAS_FLAG)
18362 {
18363
1/2
✓ Branch 0 taken 194 times.
✗ Branch 1 not taken.
194 if(!p_igetl(&temp_combo.usrflags,f,true))
18364 {
18365 return qe_invalid;
18366 }
18367
1/2
✓ Branch 0 taken 194 times.
✗ Branch 1 not taken.
194 if(!p_igetw(&temp_combo.genflags,f,true))
18368 {
18369 return qe_invalid;
18370 }
18371 194 }
18372
2/2
✓ Branch 0 taken 4696 times.
✓ Branch 1 taken 27 times.
4723 if(combo_has_flags&CHAS_TRIG)
18373 {
18374
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 27 times.
108 for ( int32_t q = 0; q < 3; q++ )
18375 {
18376
1/2
✓ Branch 0 taken 81 times.
✗ Branch 1 not taken.
81 if(!p_igetl(&temp_combo.triggerflags[q],f,true))
18377 {
18378 return qe_invalid;
18379 }
18380 81 }
18381
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 if(!p_igetl(&temp_combo.triggerlevel,f,true))
18382 {
18383 return qe_invalid;
18384 }
18385
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 if(!p_getc(&temp_combo.triggerbtn,f,true))
18386 {
18387 return qe_invalid;
18388 }
18389
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 if(!p_getc(&temp_combo.triggeritem,f,true))
18390 {
18391 return qe_invalid;
18392 }
18393
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 if(!p_getc(&temp_combo.trigtimer,f,true))
18394 {
18395 return qe_invalid;
18396 }
18397
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 if(!p_getc(&temp_combo.trigsfx,f,true))
18398 {
18399 return qe_invalid;
18400 }
18401
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 if(!p_igetl(&temp_combo.trigchange,f,true))
18402 {
18403 return qe_invalid;
18404 }
18405
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 if(!p_igetw(&temp_combo.trigprox,f,true))
18406 {
18407 return qe_invalid;
18408 }
18409
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 if(!p_getc(&temp_combo.trigctr,f,true))
18410 {
18411 return qe_invalid;
18412 }
18413
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 if(!p_igetl(&temp_combo.trigctramnt,f,true))
18414 {
18415 return qe_invalid;
18416 }
18417
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 if(!p_getc(&temp_combo.triglbeam,f,true))
18418 {
18419 return qe_invalid;
18420 }
18421
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 if(!p_getc(&temp_combo.trigcschange,f,true))
18422 {
18423 return qe_invalid;
18424 }
18425
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 if(!p_igetw(&temp_combo.spawnitem,f,true))
18426 {
18427 return qe_invalid;
18428 }
18429
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 if(!p_igetw(&temp_combo.spawnenemy,f,true))
18430 {
18431 return qe_invalid;
18432 }
18433
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 if(!p_getc(&temp_combo.exstate,f,true))
18434 {
18435 return qe_invalid;
18436 }
18437
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 if(!p_igetl(&temp_combo.spawnip,f,true))
18438 {
18439 return qe_invalid;
18440 }
18441
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 if(!p_getc(&temp_combo.trigcopycat,f,true))
18442 {
18443 return qe_invalid;
18444 }
18445
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 if(!p_getc(&temp_combo.trigcooldown,f,true))
18446 {
18447 return qe_invalid;
18448 }
18449
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27 times.
27 if(s_version >= 35)
18450 {
18451
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 if(!p_igetw(&temp_combo.prompt_cid,f,true))
18452 {
18453 return qe_invalid;
18454 }
18455
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 if(!p_getc(&temp_combo.prompt_cs,f,true))
18456 {
18457 return qe_invalid;
18458 }
18459
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 if(!p_igetw(&temp_combo.prompt_x,f,true))
18460 {
18461 return qe_invalid;
18462 }
18463
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27 times.
27 if(!p_igetw(&temp_combo.prompt_y,f,true))
18464 {
18465 return qe_invalid;
18466 }
18467 27 }
18468 27 }
18469
2/2
✓ Branch 0 taken 4711 times.
✓ Branch 1 taken 12 times.
4723 if(combo_has_flags&CHAS_LIFT)
18470 {
18471
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetw(&temp_combo.liftcmb,f,true))
18472 return qe_invalid;
18473
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&temp_combo.liftcs,f,true))
18474 return qe_invalid;
18475
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetw(&temp_combo.liftundercmb,f,true))
18476 return qe_invalid;
18477
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&temp_combo.liftundercs,f,true))
18478 return qe_invalid;
18479
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&temp_combo.liftdmg,f,true))
18480 return qe_invalid;
18481
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&temp_combo.liftlvl,f,true))
18482 return qe_invalid;
18483
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&temp_combo.liftitm,f,true))
18484 return qe_invalid;
18485
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&temp_combo.liftflags,f,true))
18486 return qe_invalid;
18487
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&temp_combo.liftgfx,f,true))
18488 return qe_invalid;
18489
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&temp_combo.liftsprite,f,true))
18490 return qe_invalid;
18491
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&temp_combo.liftsfx,f,true))
18492 return qe_invalid;
18493
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetw(&temp_combo.liftbreaksprite,f,true))
18494 return qe_invalid;
18495
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&temp_combo.liftbreaksfx,f,true))
18496 return qe_invalid;
18497
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(s_version >= 34)
18498 {
18499
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&temp_combo.lifthei,f,true))
18500 return qe_invalid;
18501
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&temp_combo.lifttime,f,true))
18502 return qe_invalid;
18503 12 }
18504 12 }
18505 4723 }
18506 15372 return 0;
18507 15372 }
18508 58 int32_t readcombos(PACKFILE *f, zquestheader *Header, word version, word build, word start_combo, word max_combos, bool keepdata)
18509 {
18510 58 word section_version=0;
18511 58 word section_cversion=0;
18512 58 word combos_used=0;
18513 int32_t dummy;
18514 byte padding;
18515 58 newcombo temp_combo;
18516
18517 58 reset_combo_animations();
18518 58 reset_combo_animations2();
18519 58 init_combo_classes();
18520
18521
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 if(keepdata==true) //reset combos
18522 {
18523
2/2
✓ Branch 0 taken 3786240 times.
✓ Branch 1 taken 58 times.
3786298 for(int32_t q = start_combo; q < start_combo+max_combos; ++q)
18524 3786240 combobuf[q].clear();
18525 58 }
18526
18527
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 if(version > 0x192) //Version info
18528 {
18529
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(!p_igetw(&section_version,f,true))
18530 {
18531 return qe_invalid;
18532 }
18533 58 FFCore.quest_format[vCombos] = section_version;
18534
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(!p_igetw(&section_cversion,f,true))
18535 {
18536 return qe_invalid;
18537 }
18538
18539 //section size
18540
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(!p_igetl(&dummy,f,true))
18541 {
18542 return qe_invalid;
18543 }
18544 58 }
18545
18546
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 55 times.
58 if(section_version > 32) //Cleanup time!
18547 {
18548
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_igetw(&combos_used,f,true))
18549 {
18550 return qe_invalid;
18551 }
18552
2/2
✓ Branch 0 taken 15372 times.
✓ Branch 1 taken 3 times.
15375 for(int32_t i=0; i<combos_used; i++)
18553 {
18554 15372 auto ret = readcombo_loop(f,section_version,temp_combo);
18555
1/2
✓ Branch 0 taken 15372 times.
✗ Branch 1 not taken.
15372 if(ret) return ret;
18556
2/4
✓ Branch 0 taken 15372 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 15372 times.
15372 if(keepdata==true && i>=start_combo)
18557 15372 memcpy(&combobuf[i], &temp_combo, sizeof(temp_combo));
18558 15372 }
18559 3 }
18560 else //Call the old function for all old versions
18561 {
18562 55 auto ret = readcombos_old(section_version,f,Header,version,build,start_combo,max_combos,keepdata);
18563
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
55 if(ret) return ret; //error, end read
18564 }
18565
18566
2/4
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 58 times.
✗ Branch 3 not taken.
58 if(keepdata && false/*section_version < 34*/)
18567 {
18568 for(int32_t i=start_combo; i<combos_used; i++)
18569 {
18570 newcombo& cmb = combobuf[i];
18571 //Do anything to 'cmb' needed for version handling
18572 }
18573 }
18574
18575
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 if(keepdata==true)
18576 {
18577
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 55 times.
58 if(!get_bit(quest_rules,qr_ALLOW_EDITING_COMBO_0))
18578 {
18579 3 combobuf[0].walk = 0xF0;
18580 3 combobuf[0].type = 0;
18581 3 combobuf[0].flag = 0;
18582 3 }
18583 58 }
18584
18585 58 setup_combo_animations();
18586 58 setup_combo_animations2();
18587 58 return 0;
18588 58 }
18589
18590 58 int32_t readcomboaliases(PACKFILE *f, zquestheader *Header, word version, word build, bool keepdata)
18591 {
18592 //these are here to bypass compiler warnings about unused arguments
18593 58 Header=Header;
18594 58 version=version;
18595 58 build=build;
18596
18597 int32_t dummy;
18598 58 word sversion=0, c_sversion;
18599
18600 //section version info
18601
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 if(!p_igetw(&sversion,f,true))
18602 {
18603 return qe_invalid;
18604 }
18605
18606 58 FFCore.quest_format[vComboAliases] = sversion;
18607
18608 //al_trace("Combo aliases version %d\n", sversion);
18609
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(!p_igetw(&c_sversion,f,true))
18610 {
18611 return qe_invalid;
18612 }
18613
18614 //section size
18615
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(!p_igetl(&dummy,f,true))
18616 {
18617 return qe_invalid;
18618 }
18619
18620 58 int32_t max_num_combo_aliases = MAXCOMBOALIASES;
18621
18622
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 55 times.
58 if(sversion < 3) // max saved combo alias' upped from 256 to 2048.
18623 {
18624 55 max_num_combo_aliases = MAX250COMBOALIASES;
18625 55 }
18626
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(sversion < 2) // max saved combo alias' upped from 256 to 2048.
18627 {
18628 max_num_combo_aliases = OLDMAXCOMBOALIASES;
18629 }
18630
18631
2/2
✓ Branch 0 taken 137216 times.
✓ Branch 1 taken 58 times.
137274 for(int32_t j=0; j<max_num_combo_aliases; j++)
18632 {
18633 byte width,height,mask,tempcset;
18634 int32_t count;
18635 word tempword;
18636 byte tempbyte;
18637
18638
1/2
✓ Branch 0 taken 137216 times.
✗ Branch 1 not taken.
137216 if(!p_igetw(&tempword,f,true))
18639 {
18640 return qe_invalid;
18641 }
18642
18643
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137216 times.
137216 if(keepdata)
18644 {
18645 137216 combo_aliases[j].combo = tempword;
18646 137216 }
18647
18648
1/2
✓ Branch 0 taken 137216 times.
✗ Branch 1 not taken.
137216 if(!p_getc(&tempbyte,f,true))
18649 {
18650 return qe_invalid;
18651 }
18652
18653
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137216 times.
137216 if(keepdata)
18654 {
18655 137216 combo_aliases[j].cset = tempbyte;
18656 137216 }
18657
18658
1/2
✓ Branch 0 taken 137216 times.
✗ Branch 1 not taken.
137216 if(!p_getc(&width,f,true))
18659 {
18660 return qe_invalid;
18661 }
18662
18663
1/2
✓ Branch 0 taken 137216 times.
✗ Branch 1 not taken.
137216 if(!p_getc(&height,f,true))
18664 {
18665 return qe_invalid;
18666 }
18667
18668
1/2
✓ Branch 0 taken 137216 times.
✗ Branch 1 not taken.
137216 if(!p_getc(&mask,f,true))
18669 {
18670 return qe_invalid;
18671 }
18672
18673 137216 count=(width+1)*(height+1)*(comboa_lmasktotal(mask)+1);
18674
18675
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137216 times.
137216 if(keepdata)
18676 {
18677
1/2
✓ Branch 0 taken 137216 times.
✗ Branch 1 not taken.
137216 if(combo_aliases[j].combos != NULL)
18678 {
18679
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137216 times.
137216 delete[] combo_aliases[j].combos;
18680 137216 }
18681
18682
1/2
✓ Branch 0 taken 137216 times.
✗ Branch 1 not taken.
137216 if(combo_aliases[j].csets != NULL)
18683 {
18684
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137216 times.
137216 delete[] combo_aliases[j].csets;
18685 137216 }
18686
18687 137216 combo_aliases[j].width = width;
18688 137216 combo_aliases[j].height = height;
18689 137216 combo_aliases[j].layermask = mask;
18690 137216 combo_aliases[j].combos = new word[count];
18691 137216 combo_aliases[j].csets = new byte[count];
18692 137216 }
18693
18694
2/2
✓ Branch 0 taken 137960 times.
✓ Branch 1 taken 137216 times.
275176 for(int32_t k=0; k<count; k++)
18695 {
18696
1/2
✓ Branch 0 taken 137960 times.
✗ Branch 1 not taken.
137960 if(!p_igetw(&tempword,f,true))
18697 {
18698 return qe_invalid;
18699 }
18700
18701
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137960 times.
137960 if(keepdata)
18702 {
18703 137960 combo_aliases[j].combos[k] = tempword;
18704 137960 }
18705 137960 }
18706
18707
2/2
✓ Branch 0 taken 137960 times.
✓ Branch 1 taken 137216 times.
275176 for(int32_t k=0; k<count; k++)
18708 {
18709
1/2
✓ Branch 0 taken 137960 times.
✗ Branch 1 not taken.
137960 if(!p_getc(&tempcset,f,true))
18710 {
18711 return qe_invalid;
18712 }
18713
18714
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137960 times.
137960 if(keepdata)
18715 {
18716 137960 combo_aliases[j].csets[k] = tempcset;
18717 137960 }
18718 137960 }
18719 137216 }
18720
18721 58 word num_combo_pools = 0;
18722
2/2
✓ Branch 0 taken 55 times.
✓ Branch 1 taken 3 times.
58 if(sversion >= 4)
18723 {
18724
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_igetw(&num_combo_pools,f,true))
18725 {
18726 return qe_invalid;
18727 }
18728 3 }
18729
18730
2/2
✓ Branch 0 taken 475136 times.
✓ Branch 1 taken 58 times.
475194 for(combo_pool& pool : combo_pools)
18731 {
18732 475136 pool.clear();
18733 }
18734
18735 58 combo_pool temp_cpool;
18736
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 58 times.
67 for(word cp = 0; cp < num_combo_pools; ++cp)
18737 {
18738 9 int32_t num_combos_in_pool = 0;
18739
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 if(!p_igetl(&num_combos_in_pool,f,true))
18740 {
18741 return qe_invalid;
18742 }
18743
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(num_combos_in_pool < 1) continue; //nothing to read
18744
18745
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 temp_cpool.clear();
18746
18747 int32_t cp_cid; int8_t cp_cs; word cp_quant;
18748
2/2
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 9 times.
48 for(auto q = 0; q < num_combos_in_pool; ++q)
18749 {
18750
2/4
✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 39 times.
✗ Branch 3 not taken.
39 if(!p_igetl(&cp_cid,f,true))
18751 {
18752 return qe_invalid;
18753 }
18754
2/4
✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 39 times.
✗ Branch 3 not taken.
39 if(!p_getc(&cp_cs,f,true))
18755 {
18756 return qe_invalid;
18757 }
18758
2/4
✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 39 times.
✗ Branch 3 not taken.
39 if(!p_igetw(&cp_quant,f,true))
18759 {
18760 return qe_invalid;
18761 }
18762
1/2
✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
39 temp_cpool.add(cp_cid, cp_cs, cp_quant);
18763 39 }
18764
18765
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(keepdata)
18766 {
18767
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 combo_pools[cp] = temp_cpool;
18768 9 }
18769 9 }
18770
18771 58 return 0;
18772 58 }
18773
18774 58 int32_t readcolordata(PACKFILE *f, miscQdata *Misc, word version, word build, word start_cset, word max_csets, bool keepdata)
18775 {
18776 //these are here to bypass compiler warnings about unused arguments
18777
18778 //THE *48 REFERS TO EACH CSET BEING 16 COLORS with 3 VALUES OF RGB (3*16 is 48)
18779 //Capitalized cause it'll save you a headache. -Deedee
18780 58 start_cset=start_cset;
18781 58 max_csets=max_csets;
18782 58 word s_version=0;
18783
18784 miscQdata temp_misc;
18785 58 memcpy(&temp_misc, Misc, sizeof(temp_misc));
18786
18787 byte temp_colordata[48];
18788 char temp_palname[PALNAMESIZE];
18789
18790 int32_t dummy;
18791 word palcycles;
18792
18793
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 if(version > 0x192)
18794 {
18795 //section version info
18796
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(!p_igetw(&s_version,f,true))
18797 {
18798 return qe_invalid;
18799 }
18800
18801 58 FFCore.quest_format[vCSets] = s_version;
18802
18803 //al_trace("Color data version %d\n", s_version);
18804
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(!p_igetw(&dummy,f,true))
18805 {
18806 return qe_invalid;
18807 }
18808
18809 //section size
18810
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(!p_igetl(&dummy,f,true))
18811 {
18812 return qe_invalid;
18813 }
18814 58 }
18815
2/2
✓ Branch 0 taken 55 times.
✓ Branch 1 taken 3 times.
58 if (s_version < 5)
18816 {
18817
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
✓ Branch 2 taken 55 times.
✗ Branch 3 not taken.
55 bool RealOldVerion = ((version < 0x192)||((version == 0x192)&&(build<73)));
18818
18819 //finally... section data
18820 55 int32_t q = 0;
18821 55 int32_t p = -15;
18822
2/2
✓ Branch 0 taken 13200 times.
✓ Branch 1 taken 55 times.
13255 for(int32_t i=0; i<oldpdTOTAL; ++i)
18823 {
18824 13200 memset(temp_colordata, 0, 48);
18825
18826
1/2
✓ Branch 0 taken 13200 times.
✗ Branch 1 not taken.
13200 if(!pfread(temp_colordata,48,f,true))
18827 {
18828 return qe_invalid;
18829 }
18830
18831
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13200 times.
13200 if(keepdata==true)
18832 {
18833 13200 memcpy(&colordata[q*48], temp_colordata, 48);
18834 13200 }
18835 13200 ++q;
18836
7/8
✓ Branch 0 taken 12320 times.
✓ Branch 1 taken 880 times.
✓ Branch 2 taken 935 times.
✓ Branch 3 taken 11385 times.
✓ Branch 4 taken 110 times.
✓ Branch 5 taken 825 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 110 times.
13200 if (p > 0 && (p%13)==12 && (i < oldpoSPRITE || !RealOldVerion)) //It's > 0 instead of >= 0 because it should append
18837 {
18838
1/2
✓ Branch 0 taken 935 times.
✗ Branch 1 not taken.
935 if (s_version < 5) //Bumping up the size of level palettes
18839 {
18840
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 935 times.
935 if(keepdata==true)
18841 {
18842 935 memcpy(&colordata[(q)*48], &colordata[1*48], 48);
18843 935 memcpy(&colordata[(q+1)*48], &colordata[5*48], 48);
18844 935 memcpy(&colordata[(q+2)*48], &colordata[7*48], 48);
18845 935 memcpy(&colordata[(q+3)*48], &colordata[8*48], 48);
18846 935 }
18847 935 q+=4;
18848 935 }
18849 else
18850 {
18851 for(int m = 0; m < 4; ++m)
18852 {
18853 memset(temp_colordata, 0, 48);
18854 if(!pfread(temp_colordata,48,f,true))
18855 {
18856 return qe_invalid;
18857 }
18858 if(keepdata==true)
18859 {
18860 memcpy(&colordata[q*48], temp_colordata, 48);
18861 }
18862 ++q;
18863 }
18864 }
18865 935 }
18866 13200 ++p;
18867 13200 }
18868
18869
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
55 if(RealOldVerion)
18870 {
18871 if(keepdata==true)
18872 {
18873 memcpy(colordata+(poSPRITE255*48), colordata+((q-30)*48), 30*16*3);
18874 memset(colordata+((q-30)*48), 0, ((poSPRITE255-(q-30))*48));
18875 memcpy(colordata+((poSPRITE255+11)*48), colordata+((poSPRITE255+10)*48), 48);
18876 memcpy(colordata+((poSPRITE255+10)*48), colordata+((poSPRITE255+9)*48), 48);
18877 memcpy(colordata+((poSPRITE255+9)*48), colordata+((poSPRITE255+8)*48), 48);
18878 memset(colordata+((poSPRITE255+8)*48), 0, 48);
18879 }
18880 }
18881 else
18882 {
18883 55 memset(temp_colordata, 0, 48);
18884
18885
2/2
✓ Branch 0 taken 172315 times.
✓ Branch 1 taken 55 times.
172370 for(int32_t i=0; i<newpdTOTAL-oldpdTOTAL; ++i)
18886 {
18887
1/2
✓ Branch 0 taken 172315 times.
✗ Branch 1 not taken.
172315 if(!pfread(temp_colordata,48,f,true))
18888 {
18889 return qe_invalid;
18890 }
18891
18892
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 172315 times.
172315 if(keepdata==true)
18893 {
18894 172315 memcpy(&colordata[q*48], temp_colordata, 48);
18895 172315 }
18896 172315 ++q;
18897
6/8
✓ Branch 0 taken 172315 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13255 times.
✓ Branch 3 taken 159060 times.
✓ Branch 4 taken 110 times.
✓ Branch 5 taken 13145 times.
✓ Branch 6 taken 110 times.
✗ Branch 7 not taken.
172315 if (p > 0 && (p%13)==12 && (i < (newpoSPRITE-oldpdTOTAL) || (s_version >= 4))) //It's > 0 instead of >= 0 because it should append
18898 {
18899
1/2
✓ Branch 0 taken 13255 times.
✗ Branch 1 not taken.
13255 if (s_version < 5) //Bumping up the size of level palettes
18900 {
18901
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13255 times.
13255 if(keepdata==true)
18902 {
18903 13255 memcpy(&colordata[(q)*48], &colordata[1*48], 48);
18904 13255 memcpy(&colordata[(q+1)*48], &colordata[5*48], 48);
18905 13255 memcpy(&colordata[(q+2)*48], &colordata[7*48], 48);
18906 13255 memcpy(&colordata[(q+3)*48], &colordata[8*48], 48);
18907 13255 }
18908 13255 q+=4;
18909 13255 }
18910 else
18911 {
18912 for(int m = 0; m < 4; ++m)
18913 {
18914 memset(temp_colordata, 0, 48);
18915 if(!pfread(temp_colordata,48,f,true))
18916 {
18917 return qe_invalid;
18918 }
18919 if(keepdata==true)
18920 {
18921 memcpy(&colordata[q*48], temp_colordata, 48);
18922 }
18923 ++q;
18924 }
18925 }
18926 13255 }
18927 172315 ++p;
18928 172315 }
18929
18930
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
55 if(s_version < 4)
18931 {
18932 if(keepdata==true)
18933 {
18934 memcpy(colordata+(poSPRITE255*48), colordata+((q-30)*48), 30*16*3);
18935 memset(colordata+((q-30)*48), 0, ((poSPRITE255-(q-30))*48));
18936 }
18937 }
18938 else
18939 {
18940
2/2
✓ Branch 0 taken 183040 times.
✓ Branch 1 taken 55 times.
183095 for(int32_t i=0; i<newerpdTOTAL-newpdTOTAL; ++i)
18941 {
18942
1/2
✓ Branch 0 taken 183040 times.
✗ Branch 1 not taken.
183040 if(!pfread(temp_colordata,48,f,true))
18943 {
18944 return qe_invalid;
18945 }
18946
18947
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 183040 times.
183040 if(keepdata==true)
18948 {
18949 183040 memcpy(&colordata[q*48], temp_colordata, 48);
18950 183040 }
18951 183040 ++q;
18952
5/6
✓ Branch 0 taken 183040 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14080 times.
✓ Branch 3 taken 168960 times.
✓ Branch 4 taken 110 times.
✓ Branch 5 taken 13970 times.
183040 if (p > 0 && (p%13)==12 && i < newerpoSPRITE-newpdTOTAL) //It's > 0 instead of >= 0 because it should append
18953 {
18954
1/2
✓ Branch 0 taken 13970 times.
✗ Branch 1 not taken.
13970 if (s_version < 5) //Bumping up the size of level palettes
18955 {
18956
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13970 times.
13970 if(keepdata==true)
18957 {
18958 13970 memcpy(&colordata[(q)*48], &colordata[1*48], 48);
18959 13970 memcpy(&colordata[(q+1)*48], &colordata[5*48], 48);
18960 13970 memcpy(&colordata[(q+2)*48], &colordata[7*48], 48);
18961 13970 memcpy(&colordata[(q+3)*48], &colordata[8*48], 48);
18962 13970 }
18963 13970 q+=4;
18964 13970 }
18965 else
18966 {
18967 for(int m = 0; m < 4; ++m)
18968 {
18969 memset(temp_colordata, 0, 48);
18970 if(!pfread(temp_colordata,48,f,true))
18971 {
18972 return qe_invalid;
18973 }
18974 if(keepdata==true)
18975 {
18976 memcpy(&colordata[q*48], temp_colordata, 48);
18977 }
18978 ++q;
18979 }
18980 }
18981 13970 }
18982 183040 ++p;
18983 183040 }
18984
18985 //By this point, q should be about equal to pdTOTAL255. If it isn't, I've fucked up. -Deedee
18986 }
18987 }
18988 55 }
18989 else
18990 {
18991
2/2
✓ Branch 0 taken 26247 times.
✓ Branch 1 taken 3 times.
26250 for(int32_t i=0; i<pdTOTAL255; ++i)
18992 {
18993 26247 memset(temp_colordata, 0, 48);
18994
18995
1/2
✓ Branch 0 taken 26247 times.
✗ Branch 1 not taken.
26247 if(!pfread(temp_colordata,48,f,true))
18996 {
18997 return qe_invalid;
18998 }
18999
19000
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26247 times.
26247 if(keepdata==true)
19001 {
19002 26247 memcpy(&colordata[i*48], temp_colordata, 48);
19003 26247 }
19004 26247 }
19005 }
19006
19007
2/6
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 58 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
58 if((version < 0x192)||((version == 0x192)&&(build<76)))
19008 {
19009 if(keepdata==true)
19010 {
19011 init_palnames();
19012 }
19013 }
19014 else
19015 {
19016 58 int32_t palnamestoread = 0;
19017
19018
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 if(s_version < 3)
19019 palnamestoread = OLDMAXLEVELS;
19020 else
19021 58 palnamestoread = 512;
19022
19023
2/2
✓ Branch 0 taken 29696 times.
✓ Branch 1 taken 58 times.
29754 for(int32_t i=0; i<palnamestoread; ++i)
19024 {
19025 29696 memset(temp_palname, 0, PALNAMESIZE);
19026
19027
1/2
✓ Branch 0 taken 29696 times.
✗ Branch 1 not taken.
29696 if(!pfread(temp_palname,PALNAMESIZE,f,true))
19028 {
19029 return qe_invalid;
19030 }
19031
19032
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29696 times.
29696 if(keepdata==true)
19033 {
19034 29696 memcpy(palnames[i], temp_palname, PALNAMESIZE);
19035 29696 }
19036 29696 }
19037
19038
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 if(keepdata)
19039 {
19040
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 for(int32_t i=palnamestoread; i<MAXLEVELS; i++)
19041 {
19042 memset(palnames[i], 0, PALNAMESIZE);
19043 }
19044 58 }
19045 }
19046
19047
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 if(version > 0x192)
19048 {
19049
2/2
✓ Branch 0 taken 14848 times.
✓ Branch 1 taken 58 times.
14906 for(int32_t i=0; i<256; i++)
19050 {
19051
2/2
✓ Branch 0 taken 44544 times.
✓ Branch 1 taken 14848 times.
59392 for(int32_t j=0; j<3; j++)
19052 {
19053 44544 temp_misc.cycles[i][j].first=0;
19054 44544 temp_misc.cycles[i][j].count=0;
19055 44544 temp_misc.cycles[i][j].speed=0;
19056 44544 }
19057 14848 }
19058
19059
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(!p_igetw(&palcycles,f,true))
19060 {
19061 return qe_invalid;
19062 }
19063
19064
2/2
✓ Branch 0 taken 2294 times.
✓ Branch 1 taken 58 times.
2352 for(int32_t i=0; i<palcycles; i++)
19065 {
19066
2/2
✓ Branch 0 taken 6882 times.
✓ Branch 1 taken 2294 times.
9176 for(int32_t j=0; j<3; j++)
19067 {
19068
1/2
✓ Branch 0 taken 6882 times.
✗ Branch 1 not taken.
6882 if(!p_getc(&temp_misc.cycles[i][j].first,f,true))
19069 {
19070 return qe_invalid;
19071 }
19072 6882 }
19073
19074
2/2
✓ Branch 0 taken 6882 times.
✓ Branch 1 taken 2294 times.
9176 for(int32_t j=0; j<3; j++)
19075 {
19076
1/2
✓ Branch 0 taken 6882 times.
✗ Branch 1 not taken.
6882 if(!p_getc(&temp_misc.cycles[i][j].count,f,true))
19077 {
19078 return qe_invalid;
19079 }
19080 6882 }
19081
19082
2/2
✓ Branch 0 taken 6882 times.
✓ Branch 1 taken 2294 times.
9176 for(int32_t j=0; j<3; j++)
19083 {
19084
1/2
✓ Branch 0 taken 6882 times.
✗ Branch 1 not taken.
6882 if(!p_getc(&temp_misc.cycles[i][j].speed,f,true))
19085 {
19086 return qe_invalid;
19087 }
19088 6882 }
19089 2294 }
19090
19091
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 if(keepdata==true)
19092 {
19093 58 memcpy(Misc, &temp_misc, sizeof(temp_misc));
19094 58 }
19095 58 }
19096
19097 58 return 0;
19098 58 }
19099
19100 58 int32_t readtiles(PACKFILE *f, tiledata *buf, zquestheader *Header, word version, word build, word start_tile, int32_t max_tiles, bool from_init, bool keepdata)
19101 {
19102 58 int32_t tiles_used=0;
19103 58 word section_version = 0;
19104 58 word section_cversion = 0;
19105 58 int32_t section_size= 0;
19106 58 byte *temp_tile = new byte[tilesize(tf32Bit)];
19107
19108 //Tile Expansion
19109 //if ( version >= 0x254 && build >= 41 )
19110
3/4
✓ Branch 0 taken 55 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 55 times.
58 if (version < 0x254 && build < 41)
19111 {
19112 //al_trace("Build was < 41 when reading tiles\n");
19113 55 max_tiles = ZC250MAXTILES;
19114 55 }
19115
19116 //al_trace("Max Tiles: %d\n", max_tiles);
19117
19118
2/6
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 58 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
58 if(Header!=NULL&&(!Header->data_flags[ZQ_TILES]&&!from_init)) //keep for old quests
19119 {
19120 if(keepdata==true)
19121 {
19122 if(!init_tiles(true, Header))
19123 {
19124 al_trace("Unable to initialize tiles\n");
19125 }
19126 }
19127
19128 delete[] temp_tile;
19129 temp_tile=NULL;
19130 return 0;
19131 }
19132 else
19133 {
19134
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 if(version > 0x192)
19135 {
19136 //section version info
19137
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(!p_igetw(&section_version,f,true))
19138 {
19139 delete[] temp_tile;
19140 return qe_invalid;
19141 }
19142
19143 58 FFCore.quest_format[vTiles] = section_version;
19144
19145
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(!p_igetw(&section_cversion,f,true))
19146 {
19147 delete[] temp_tile;
19148 return qe_invalid;
19149 }
19150
19151 //section size
19152
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(!p_igetl(&section_size,f,true))
19153 {
19154 delete[] temp_tile;
19155 return qe_invalid;
19156 }
19157 58 }
19158
19159 //if ( build < 41 )
19160 //{
19161 // tiles_used = ZC250MAXTILES;
19162 //}
19163
19164
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 if(version < 0x174)
19165 {
19166 tiles_used=TILES_PER_PAGE*4;
19167 } //no expanded tile space
19168
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 else if(version < 0x191)
19169 {
19170 tiles_used=OLDMAXTILES;
19171 }
19172 else
19173 {
19174 //finally... section data
19175
3/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 55 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
58 if ( version >= 0x254 && build >= 41 ) //read and write the size of tiles_used properly
19176 {
19177
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_igetl(&tiles_used,f,true))
19178 {
19179 delete[] temp_tile;
19180 return qe_invalid;
19181 }
19182 3 }
19183 else
19184 {
19185
1/2
✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
55 if(!p_igetw(&tiles_used,f,true))
19186 {
19187 delete[] temp_tile;
19188 return qe_invalid;
19189 }
19190 }
19191 }
19192
19193
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 tiles_used=zc_min(tiles_used, max_tiles);
19194
19195 //if ( version < 0x254 || ( version >= 0x254 && build < 41 )) //don't do this, it crashes ZQuest. -Z
19196 //if ( version < 0x254 && build < 41 )
19197
3/6
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 55 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
58 if ( version < 0x254 || (version == 0x254 && build < 41) )
19198 //if ( build < 41 )
19199 {
19200
1/2
✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
55 tiles_used=zc_min(tiles_used, ZC250MAXTILES-start_tile);
19201 55 }
19202 else //2.55
19203 {
19204
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 tiles_used = zc_min(tiles_used,NEWMAXTILES-start_tile);
19205 }
19206
19207 //if ( section_version > 1 ) tiles_used = NEWMAXTILES;
19208
19209 //al_trace("tiles_used = %d\n", tiles_used);
19210
19211
2/2
✓ Branch 0 taken 841590 times.
✓ Branch 1 taken 58 times.
841648 for(int32_t i=0; i<tiles_used; ++i)
19212 {
19213 841590 byte format=tf4Bit;
19214 841590 memset(temp_tile, 0, tilesize(tf32Bit));
19215
19216
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 841590 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
841590 if((version>0x211)||((version==0x211)&&(build>4)))
19217 {
19218
1/2
✓ Branch 0 taken 841590 times.
✗ Branch 1 not taken.
841590 if(!p_getc(&format,f,true))
19219 {
19220 delete[] temp_tile;
19221 return qe_invalid;
19222 }
19223 841590 }
19224
4/4
✓ Branch 0 taken 70156 times.
✓ Branch 1 taken 771434 times.
✓ Branch 2 taken 34845 times.
✓ Branch 3 taken 35311 times.
841590 if(section_version > 2 && !format)
19225 {
19226
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35311 times.
35311 if(keepdata)
19227 {
19228 35311 reset_tile(buf,start_tile+i,tf4Bit);
19229 35311 }
19230 35311 continue;
19231 }
19232
19233
1/2
✓ Branch 0 taken 806279 times.
✗ Branch 1 not taken.
806279 if(!pfread(temp_tile,tilesize(format),f,true))
19234 {
19235 delete[] temp_tile;
19236 return qe_invalid;
19237 }
19238
19239
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 806279 times.
806279 if(keepdata==true)
19240 {
19241 806279 buf[start_tile+i].format=format;
19242
19243
1/2
✓ Branch 0 taken 806279 times.
✗ Branch 1 not taken.
806279 if(buf[start_tile+i].data)
19244 {
19245 806279 free(buf[start_tile+i].data);
19246 806279 buf[start_tile+i].data=NULL;
19247 806279 }
19248
19249 806279 buf[start_tile+i].data=(byte *)malloc(tilesize(buf[start_tile+i].format));
19250 806279 memcpy(buf[start_tile+i].data,temp_tile,tilesize(buf[start_tile+i].format));
19251 806279 }
19252 806279 }
19253 }
19254
19255
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 55 times.
58 if ( section_version < 2 ) //write blank tile data --check s_version with this again instead?
19256 {
19257 //al_trace("Writing blank tile data to new tiles for build < 41\n");
19258
2/2
✓ Branch 0 taken 8193900 times.
✓ Branch 1 taken 55 times.
8193955 for ( int32_t q = ZC250MAXTILES; q < NEWMAXTILES; ++q )
19259 {
19260
19261 //memcpy(buf[q].data,temp_tile,tilesize(buf[q].format));
19262 8193900 reset_tile(buf,q,tf4Bit);
19263
19264
19265 /*
19266
19267 byte tempbyte;
19268 for(int32_t i=0; i<tilesize(tf4Bit); i++)
19269 {
19270 tempbyte=buf[ZC250MAXTILES-1].data[i];
19271 buf[q].data[i] = tempbyte;
19272 }
19273 //int32_t temp = tempbyte=buf[130].data[i];
19274 //buf[q].data = buf[ZC250MAXTILES-1].data;
19275 */
19276 //reset_tile(buf,q,tf4Bit);
19277 8193900 }
19278
19279 55 }
19280
19281
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 if(keepdata==true)
19282 {
19283
4/6
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 55 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
58 if ( version < 0x254 || ( version >= 0x254 && build < 41 ))
19284 {
19285
2/2
✓ Branch 0 taken 2867244 times.
✓ Branch 1 taken 55 times.
2867299 for(int32_t i=start_tile+tiles_used; i<max_tiles; ++i)
19286 {
19287 //al_trace("Resetting tiles for ZC250MAXTILES, iteration: %d\n", i);
19288 2867244 reset_tile(buf,i,tf4Bit);
19289 2867244 }
19290 55 }
19291 else
19292 {
19293
2/2
✓ Branch 0 taken 538266 times.
✓ Branch 1 taken 3 times.
538269 for(int32_t i=start_tile+tiles_used; i<max_tiles; ++i)
19294 {
19295 //al_trace("Resetting tiles for build 41+\n");
19296 538266 reset_tile(buf,i,tf4Bit);
19297 538266 }
19298 }
19299
19300
2/6
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 58 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
58 if((version < 0x192)|| ((version == 0x192)&&(build<186)))
19301 {
19302 if(get_bit(quest_rules,qr_BSZELDA)) //
19303 {
19304 byte tempbyte;
19305 int32_t floattile=wpnsbuf[iwSwim].tile;
19306
19307 for(int32_t i=0; i<tilesize(tf4Bit); i++) //BSZelda tiles are out of order //does this include swim tiles?
19308 {
19309 tempbyte=buf[23].data[i];
19310 buf[23].data[i]=buf[24].data[i];
19311 buf[24].data[i]=buf[25].data[i];
19312 buf[25].data[i]=buf[26].data[i];
19313 buf[26].data[i]=tempbyte;
19314 }
19315 //swim tiles are out of order, too, but nobody cared? -Z
19316 for(int32_t i=0; i<tilesize(tf4Bit); i++)
19317 {
19318 tempbyte=buf[floattile+11].data[i];
19319 buf[floattile+11].data[i]=buf[floattile+12].data[i];
19320 buf[floattile+12].data[i]=tempbyte;
19321 }
19322 }
19323 }
19324
19325
2/6
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 58 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
58 if((version < 0x211)||((version == 0x211)&&(build<7))) //Goriya tiles are out of order
19326 {
19327 if(!get_bit(quest_rules,qr_NEWENEMYTILES))
19328 {
19329 byte tempbyte;
19330
19331 for(int32_t i=0; i<tilesize(tf4Bit); i++)
19332 {
19333 tempbyte=buf[130].data[i];
19334 buf[130].data[i]=buf[132].data[i];
19335 buf[132].data[i]=tempbyte;
19336
19337 tempbyte=buf[131].data[i];
19338 buf[131].data[i]=buf[133].data[i];
19339 buf[133].data[i]=tempbyte;
19340 }
19341 }
19342 }
19343
19344 58 al_trace("Registering blank tiles\n");
19345 58 register_blank_tiles();
19346 58 }
19347
19348 //memset(temp_tile, 0, tilesize(tf32Bit));
19349
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 delete[] temp_tile;
19350 58 temp_tile=NULL;
19351 58 return 0;
19352 58 }
19353
19354 58 int32_t readtunes(PACKFILE *f, zquestheader *Header, zctune *tunes /*zcmidi_ *midis*/, bool keepdata)
19355 {
19356 58 byte *mf=midi_flags;
19357 int32_t dummy;
19358 word dummy2;
19359 // zcmidi_ temp_midi;
19360 int32_t tunes_to_read;
19361 58 int32_t tune_count=0;
19362 58 word section_version=0;
19363 58 zctune temp;
19364
19365
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 if(Header->zelda_version < 0x193)
19366 {
19367 // mf=Header->data_flags+ZQ_MIDIS2;
19368 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<178)))
19369 {
19370 tunes_to_read=MAXCUSTOMMIDIS192b177;
19371 }
19372 else
19373 {
19374 tunes_to_read=MAXCUSTOMTUNES;
19375 }
19376 }
19377 else
19378 {
19379 //section version info
19380
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(!p_igetw(&section_version,f,true))
19381 {
19382 return qe_invalid;
19383 }
19384
19385 58 FFCore.quest_format[vMIDIs] = section_version;
19386
19387 //al_trace("Tunes version %d\n", section_version);
19388
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(!p_igetw(&dummy2,f,true))
19389 {
19390 return qe_invalid;
19391 }
19392
19393 //section size
19394
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(!p_igetl(&dummy,f,true))
19395 {
19396 return qe_invalid;
19397 }
19398
19399 //finally... section data
19400
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(!pfread(midi_flags,sizeof(midi_flags),f,true))
19401 {
19402 return qe_invalid;
19403 }
19404
19405 58 tunes_to_read=MAXCUSTOMTUNES;
19406 }
19407
19408
2/2
✓ Branch 0 taken 14616 times.
✓ Branch 1 taken 58 times.
14674 for(int32_t i=0; i<MAXCUSTOMTUNES; ++i)
19409 {
19410
2/2
✓ Branch 0 taken 13435 times.
✓ Branch 1 taken 1181 times.
14616 if(get_bit(mf, i))
19411 {
19412 1181 ++tune_count;
19413 1181 }
19414 14616 }
19415
19416
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 if(keepdata==true)
19417 {
19418 58 reset_tunes(tunes); //reset_midis(midis);
19419 58 }
19420
19421
2/2
✓ Branch 0 taken 14616 times.
✓ Branch 1 taken 58 times.
14674 for(int32_t i=0; i<tunes_to_read; i++)
19422 {
19423 14616 temp.clear(); //memset(&temp_midi,0,sizeof(zcmidi_));
19424
19425
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14616 times.
14616 if(keepdata==true)
19426 {
19427 14616 tunes[i].reset(); // reset_midi(midis+i);
19428 14616 }
19429
19430
2/2
✓ Branch 0 taken 13435 times.
✓ Branch 1 taken 1181 times.
14616 if(get_bit(mf,i))
19431 {
19432
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1181 times.
1181 if(section_version < 4)
19433 {
19434 if(!pfread(&temp.title,sizeof(char)*20,f,true))
19435 {
19436 return qe_invalid;
19437 }
19438 }
19439 else
19440 {
19441
1/2
✓ Branch 0 taken 1181 times.
✗ Branch 1 not taken.
1181 if(!pfread(&temp.title,sizeof(temp.title),f,true))
19442 {
19443 return qe_invalid;
19444 }
19445 }
19446
19447
1/2
✓ Branch 0 taken 1181 times.
✗ Branch 1 not taken.
1181 if(!p_igetl(&temp.start,f,true))
19448 {
19449 return qe_invalid;
19450 }
19451
19452
1/2
✓ Branch 0 taken 1181 times.
✗ Branch 1 not taken.
1181 if(!p_igetl(&temp.loop_start,f,true))
19453 {
19454 return qe_invalid;
19455 }
19456
19457
1/2
✓ Branch 0 taken 1181 times.
✗ Branch 1 not taken.
1181 if(!p_igetl(&temp.loop_end,f,true))
19458 {
19459 return qe_invalid;
19460 }
19461
19462
1/2
✓ Branch 0 taken 1181 times.
✗ Branch 1 not taken.
1181 if(!p_igetw(&temp.loop,f,true))
19463 {
19464 return qe_invalid;
19465 }
19466
19467
1/2
✓ Branch 0 taken 1181 times.
✗ Branch 1 not taken.
1181 if(!p_igetw(&temp.volume,f,true))
19468 {
19469 return qe_invalid;
19470 }
19471
19472
1/2
✓ Branch 0 taken 1181 times.
✗ Branch 1 not taken.
1181 if(Header->zelda_version < 0x193)
19473 {
19474 if(!p_igetl(&dummy,f,true))
19475 {
19476 return qe_invalid;
19477 }
19478 }
19479
19480
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1181 times.
1181 if(section_version >= 3)
19481 {
19482
1/2
✓ Branch 0 taken 1181 times.
✗ Branch 1 not taken.
1181 if(!pfread(&temp.flags,sizeof(temp.flags),f,true))
19483 {
19484 return qe_invalid;
19485 }
19486 1181 }
19487
19488
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1181 times.
1181 if(keepdata==true)
19489 {
19490 1181 tunes[i].copyfrom(temp); // memcpy(&midis[i], &temp_midi, sizeof(zcmidi_));
19491 1181 }
19492
19493
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1181 times.
1181 if(section_version < 2) //= 1 || (Header->zelda_version < 0x211) || (Header->zelda_version == 0x211 && Header->build < 18))
19494 {
19495 // old format - a midi is a midi
19496 if(((keepdata==true?tunes[i].data:temp.data)=read_midi(f, true))==NULL)
19497 {
19498 return qe_invalid;
19499 }
19500
19501 //yes you can do this. Isn't the ? operator awesome? :)
19502 (keepdata ? tunes[i] : temp).format = MFORMAT_MIDI;
19503 }
19504 else
19505 {
19506 // 'midi' could be midi or nes, gb, ... music
19507
2/4
✓ Branch 0 taken 1181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1181 times.
✗ Branch 3 not taken.
1181 if(!pfread(&(keepdata ? tunes[i] : temp).format,sizeof((keepdata ? tunes[i] : temp).format),f,true))
19508 {
19509 return qe_invalid;
19510 }
19511
19512
1/2
✓ Branch 0 taken 1181 times.
✗ Branch 1 not taken.
1181 zctune *ptr = (keepdata==true)?&(tunes[i]):&temp;
19513
19514
1/2
✓ Branch 0 taken 1181 times.
✗ Branch 1 not taken.
1181 switch(temp.format)
19515 {
19516 case MFORMAT_MIDI:
19517
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1181 times.
1181 if((ptr->data=read_midi(f, true))==NULL)
19518 {
19519 return qe_invalid;
19520 }
19521
19522 1181 break;
19523
19524 default:
19525 return qe_invalid;
19526 break;
19527 }
19528 }
19529 1181 }
19530 14616 }
19531
19532 58 return 0;
19533 58 }
19534
19535 58 int32_t readcheatcodes(PACKFILE *f, zquestheader *Header, bool keepdata)
19536 {
19537 int32_t dummy;
19538 ZCHEATS tempzcheats;
19539 58 char temp_use_cheats=1;
19540 58 memset(&tempzcheats, 0, sizeof(tempzcheats));
19541 58 word s_version = 0;
19542
19543
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 if(Header->zelda_version > 0x192)
19544 {
19545 //section version info
19546
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(!p_igetw(&s_version,f,true))
19547 {
19548 return qe_invalid;
19549 }
19550
19551 58 FFCore.quest_format[vCheats] = s_version;
19552 //al_trace("Cheats version %d\n", dummy);
19553
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(!p_igetw(&dummy,f,true))
19554 {
19555 return qe_invalid;
19556 }
19557
19558 //section size
19559
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(!p_igetl(&dummy,f,true))
19560 {
19561 return qe_invalid;
19562 }
19563
19564 //finally... section data
19565
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 if(!p_getc(&temp_use_cheats,f,true))
19566 {
19567 return qe_invalid;
19568 }
19569 58 }
19570
19571
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 if(Header->data_flags[ZQ_CHEATS2])
19572 {
19573
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(!p_igetl(&tempzcheats.flags,f,true))
19574 {
19575 return qe_invalid;
19576 }
19577
19578
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(!pfread(&tempzcheats.codes, sizeof(tempzcheats.codes), f,true))
19579 {
19580 return qe_invalid;
19581 }
19582 58 }
19583
19584
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 if(keepdata==true)
19585 {
19586 58 memcpy(&zcheats, &tempzcheats, sizeof(tempzcheats));
19587 58 Header->data_flags[ZQ_CHEATS2]=temp_use_cheats;
19588 58 }
19589
19590 58 return 0;
19591 58 }
19592
19593 168 int32_t readinitdata(PACKFILE *f, zquestheader *Header, bool keepdata)
19594 {
19595 int32_t dummy;
19596 168 word s_version=0, s_cversion=0;
19597 byte padding;
19598 word tempw;
19599
19600 168 zinitdata temp_zinit;
19601
19602 // Legacy item properties (now integrated into itemdata)
19603 byte sword_hearts[4];
19604 byte beam_hearts[4];
19605 168 byte beam_percent=0;
19606 word beam_power[4];
19607 168 byte hookshot_length=99;
19608 168 byte hookshot_links=100;
19609 168 byte longshot_length=99;
19610 168 byte longshot_links=100;
19611 168 byte moving_fairy_hearts=3;
19612 168 byte moving_fairy_heart_percent=0;
19613 168 byte stationary_fairy_hearts=3;
19614 168 byte stationary_fairy_heart_percent=0;
19615 168 byte moving_fairy_magic=0;
19616 168 byte moving_fairy_magic_percent=0;
19617 168 byte stationary_fairy_magic=0;
19618 168 byte stationary_fairy_magic_percent=0;
19619 168 byte blue_potion_hearts=100;
19620 168 byte blue_potion_heart_percent=1;
19621 168 byte red_potion_hearts=100;
19622 168 byte red_potion_heart_percent=1;
19623 168 byte blue_potion_magic=100;
19624 168 byte blue_potion_magic_percent=1;
19625 168 byte red_potion_magic=100;
19626 168 byte red_potion_magic_percent=1;
19627
19628
2/2
✓ Branch 0 taken 58 times.
✓ Branch 1 taken 110 times.
168 temp_zinit.subscreen_style=get_bit(quest_rules,qr_COOLSCROLL)?1:0;
19629
19630
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(Header->zelda_version > 0x192)
19631 {
19632 //section version info
19633
2/4
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 58 times.
✗ Branch 3 not taken.
58 if(!p_igetw(&s_version,f,true))
19634 {
19635 return qe_invalid;
19636 }
19637
19638 58 FFCore.quest_format[vInitData] = s_version;
19639
19640 //al_trace("Init data version %d\n", s_version);
19641
2/4
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 58 times.
✗ Branch 3 not taken.
58 if(!p_igetw(&s_cversion,f,true))
19642 {
19643 return qe_invalid;
19644 }
19645
19646 //section size
19647
2/4
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 58 times.
✗ Branch 3 not taken.
58 if(!p_igetl(&dummy,f,true))
19648 {
19649 return qe_invalid;
19650 }
19651 58 }
19652
19653 /* HIGHLY UNORTHODOX UPDATING THING, by L
19654 * This fixes quests made before revision 277 (such as the 'Lost Isle Build'),
19655 * where the speed of Pols Voice changed. It also coincided with V_INITDATA
19656 * changing from 13 to 14.
19657 */
19658
2/4
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 58 times.
✗ Branch 3 not taken.
58 if(keepdata && s_version < 14)
19659 fixpolsvoice=true;
19660
19661 /* End highly unorthodox updating thing */
19662
19663
4/6
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 58 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 55 times.
✓ Branch 5 taken 3 times.
58 if(s_version >= 15 && get_bit(deprecated_rules, 27)) // The int16_t-lived rule, qr_JUMPHEROLAYER3
19664 3 temp_zinit.jump_hero_layer_threshold=0;
19665
19666
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 if(s_version >= 10)
19667 {
19668 char temp;
19669
19670 //new-style items
19671
2/2
✓ Branch 0 taken 14848 times.
✓ Branch 1 taken 58 times.
14906 for(int32_t j=0; j<256; j++)
19672 {
19673
2/4
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14848 times.
14848 if(!p_getc(&temp,f,true))
19674 return qe_invalid;
19675
19676 14848 temp_zinit.items[j] = (temp != 0);
19677 14848 }
19678 58 }
19679
19680
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 52 times.
✓ Branch 5 taken 52 times.
58 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>26)))
19681 {
19682 char temp;
19683
19684 //finally... section data
19685
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 52 times.
✓ Branch 3 taken 52 times.
110 if((Header->zelda_version > 0x192)||
19686 //new only
19687 ((Header->zelda_version == 0x192)&&(Header->build>173)))
19688 {
19689 //OLD-style items... sigh
19690
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 if(s_version < 10)
19691 {
19692 if(!p_getc(&temp,f,true))
19693 {
19694 return qe_invalid;
19695 }
19696
19697 temp_zinit.items[iRaft]=(temp != 0);
19698
19699 if(!p_getc(&temp,f,true))
19700 {
19701 return qe_invalid;
19702 }
19703
19704 temp_zinit.items[iLadder]=(temp != 0);
19705
19706 if(!p_getc(&temp,f,true))
19707 {
19708 return qe_invalid;
19709 }
19710
19711 temp_zinit.items[iBook]=(temp != 0);
19712
19713 if(!p_getc(&temp,f,true))
19714 {
19715 return qe_invalid;
19716 }
19717
19718 temp_zinit.items[iMKey]=(temp!=0);
19719
19720 if(!p_getc(&temp,f,true))
19721 {
19722 return qe_invalid;
19723 }
19724
19725 temp_zinit.items[iFlippers]=(temp != 0);
19726
19727 if(!p_getc(&temp,f,true))
19728 {
19729 return qe_invalid;
19730 }
19731
19732 temp_zinit.items[iBoots]=(temp!=0);
19733 }
19734 58 }
19735
19736
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 110 times.
110 if(s_version < 10)
19737 {
19738 char tempring, tempsword, tempshield, tempwallet, tempbracelet, tempamulet, tempbow;
19739
19740 if(!p_getc(&tempring,f,true))
19741 {
19742 return qe_invalid;
19743 }
19744
19745 if(!p_getc(&tempsword,f,true))
19746 {
19747 return qe_invalid;
19748 }
19749
19750 if(!p_getc(&tempshield,f,true))
19751 {
19752 return qe_invalid;
19753 }
19754
19755 if(!p_getc(&tempwallet,f,true))
19756 {
19757 return qe_invalid;
19758 }
19759
19760 if(!p_getc(&tempbracelet,f,true))
19761 {
19762 return qe_invalid;
19763 }
19764
19765 if(!p_getc(&tempamulet,f,true))
19766 {
19767 return qe_invalid;
19768 }
19769
19770 if(!p_getc(&tempbow,f,true))
19771 {
19772 return qe_invalid;
19773 }
19774
19775 //old only
19776 if((Header->zelda_version == 0x192)&&(Header->build<174))
19777 {
19778 tempring=(tempring)?(1<<(tempring-1)):0;
19779 tempsword=(tempsword)?(1<<(tempsword-1)):0;
19780 tempshield=(tempshield)?(1<<(tempshield-1)):0;
19781 tempwallet=(tempwallet)?(1<<(tempwallet-1)):0;
19782 tempbracelet=(tempbracelet)?(1<<(tempbracelet-1)):0;
19783 tempamulet=(tempamulet)?(1<<(tempamulet-1)):0;
19784 tempbow=(tempbow)?(1<<(tempbow-1)):0;
19785 }
19786
19787 //rings start at level 2... wtf
19788 //account for this -DD
19789 tempring <<= 1;
19790 addOldStyleFamily(&temp_zinit, itemsbuf, itype_ring, tempring);
19791 addOldStyleFamily(&temp_zinit, itemsbuf, itype_sword, tempsword);
19792 addOldStyleFamily(&temp_zinit, itemsbuf, itype_shield, tempshield);
19793 addOldStyleFamily(&temp_zinit, itemsbuf, itype_wallet, tempwallet);
19794 //bracelet ALSO starts at level 2 :-( -DD
19795 tempbracelet<<=1;
19796 addOldStyleFamily(&temp_zinit, itemsbuf, itype_bracelet, tempbracelet);
19797 addOldStyleFamily(&temp_zinit, itemsbuf, itype_amulet, tempamulet);
19798 addOldStyleFamily(&temp_zinit, itemsbuf, itype_bow, tempbow);
19799
19800 //new only
19801 if((Header->zelda_version == 0x192)&&(Header->build>173))
19802 {
19803 for(int32_t q=0; q<32; q++)
19804 {
19805 if(!p_getc(&padding,f,true))
19806 {
19807 return qe_invalid;
19808 }
19809 }
19810 }
19811
19812 char tempcandle, tempboomerang, temparrow, tempwhistle;
19813
19814 if(!p_getc(&tempcandle,f,true))
19815 {
19816 return qe_invalid;
19817 }
19818
19819 if(!p_getc(&tempboomerang,f,true))
19820 {
19821 return qe_invalid;
19822 }
19823
19824 if(!p_getc(&temparrow,f,true))
19825 {
19826 return qe_invalid;
19827 }
19828
19829 if(!p_getc(&temp,f,true))
19830 {
19831 return qe_invalid;
19832 }
19833
19834 addOldStyleFamily(&temp_zinit, itemsbuf, itype_potion, temp);
19835
19836 if(!p_getc(&tempwhistle,f,true))
19837 {
19838 return qe_invalid;
19839 }
19840
19841 //old only
19842 if((Header->zelda_version == 0x192)&&(Header->build<174))
19843 {
19844 tempcandle=(tempcandle)?(1<<(tempcandle-1)):0;
19845 tempboomerang=(tempboomerang)?(1<<(tempboomerang-1)):0;
19846 temparrow=(temparrow)?(1<<(temparrow-1)):0;
19847 tempwhistle=(tempwhistle)?(1<<(tempwhistle-1)):0;
19848 }
19849
19850 addOldStyleFamily(&temp_zinit, itemsbuf, itype_candle, tempcandle);
19851 addOldStyleFamily(&temp_zinit, itemsbuf, itype_brang, tempboomerang);
19852 addOldStyleFamily(&temp_zinit, itemsbuf, itype_arrow, temparrow);
19853 addOldStyleFamily(&temp_zinit, itemsbuf, itype_whistle, tempwhistle);
19854 //What about the potion...?
19855
19856 }
19857
19858
2/2
✓ Branch 0 taken 55 times.
✓ Branch 1 taken 55 times.
110 if(s_version < 29)
19859 {
19860 //Oh sure, stick these IN THE MIDDLE OF THE ITEMS, just to make me want
19861 //to jab out my eye...
19862
2/4
✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 55 times.
✗ Branch 3 not taken.
55 if(!p_getc(&padding,f,true))
19863 return qe_invalid;
19864 55 temp_zinit.bombs = padding;
19865
19866
2/4
✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 55 times.
✗ Branch 3 not taken.
55 if(!p_getc(&padding,f,true))
19867 return qe_invalid;
19868 55 temp_zinit.super_bombs = padding;
19869 55 }
19870
19871 //Back to more OLD item code
19872
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
110 if(s_version < 10)
19873 {
19874 if((Header->zelda_version > 0x192)||
19875 //new only
19876 ((Header->zelda_version == 0x192)&&(Header->build>173)))
19877 {
19878 if(!p_getc(&temp,f,true))
19879 {
19880 return qe_invalid;
19881 }
19882
19883 addOldStyleFamily(&temp_zinit, itemsbuf, itype_wand, temp);
19884
19885 if(!p_getc(&temp,f,true))
19886 {
19887 return qe_invalid;
19888 }
19889
19890 addOldStyleFamily(&temp_zinit, itemsbuf, itype_letter, temp);
19891
19892 if(!p_getc(&temp,f,true))
19893 {
19894 return qe_invalid;
19895 }
19896
19897 addOldStyleFamily(&temp_zinit, itemsbuf, itype_lens, temp);
19898
19899 if(!p_getc(&temp,f,true))
19900 {
19901 return qe_invalid;
19902 }
19903
19904 addOldStyleFamily(&temp_zinit, itemsbuf, itype_hookshot, temp);
19905
19906 if(!p_getc(&temp,f,true))
19907 {
19908 return qe_invalid;
19909 }
19910
19911 addOldStyleFamily(&temp_zinit, itemsbuf, itype_bait, temp);
19912
19913 if(!p_getc(&temp,f,true))
19914 {
19915 return qe_invalid;
19916 }
19917
19918 addOldStyleFamily(&temp_zinit, itemsbuf, itype_hammer, temp);
19919
19920 if(!p_getc(&temp,f,true))
19921 {
19922 return qe_invalid;
19923 }
19924
19925 addOldStyleFamily(&temp_zinit, itemsbuf, itype_dinsfire, temp);
19926
19927 if(!p_getc(&temp,f,true))
19928 {
19929 return qe_invalid;
19930 }
19931
19932 addOldStyleFamily(&temp_zinit, itemsbuf, itype_faroreswind, temp);
19933
19934 if(!p_getc(&temp,f,true))
19935 {
19936 return qe_invalid;
19937 }
19938
19939 addOldStyleFamily(&temp_zinit, itemsbuf, itype_nayruslove, temp);
19940
19941 if(!p_getc(&temp,f,true))
19942 {
19943 return qe_invalid;
19944 }
19945
19946 if(Header->zelda_version == 0x192)
19947 {
19948 for(int32_t q=0; q<32; q++)
19949 {
19950 if(!p_getc(&padding,f,true))
19951 {
19952 return qe_invalid;
19953 }
19954 }
19955 }
19956 }
19957 }
19958
19959 //old only
19960 if((Header->zelda_version == 0x192)&&(Header->build<174))
19961 {
19962 byte equipment, items; //bit flags
19963
19964 if(!p_getc(&equipment,f,true))
19965 {
19966 return qe_invalid;
19967 }
19968
19969 temp_zinit.items[iRaft]=(get_bit(&equipment, idE_RAFT)!=0);
19970 temp_zinit.items[iLadder]=(get_bit(&equipment, idE_LADDER)!=0);
19971 temp_zinit.items[iBook]=(get_bit(&equipment, idE_BOOK)!=0);
19972 temp_zinit.items[iMKey]=(get_bit(&equipment, idE_KEY)!=0);
19973 temp_zinit.items[iFlippers]=(get_bit(&equipment, idE_FLIPPERS)!=0);
19974 temp_zinit.items[iBoots]=(get_bit(&equipment, idE_BOOTS)!=0);
19975
19976
19977 if(!p_getc(&items,f,true))
19978 {
19979 return qe_invalid;
19980 }
19981
19982 temp_zinit.items[iWand]=(get_bit(&items, idI_WAND)!=0);
19983 temp_zinit.items[iLetter]=(get_bit(&items, idI_LETTER)!=0);
19984 temp_zinit.items[iLens]=(get_bit(&items, idI_LENS)!=0);
19985 temp_zinit.items[iHookshot]=(get_bit(&items, idI_HOOKSHOT)!=0);
19986 temp_zinit.items[iBait]=(get_bit(&items, idI_BAIT)!=0);
19987 temp_zinit.items[iHammer]=(get_bit(&items, idI_HAMMER)!=0);
19988 }
19989
19990 if(!p_getc(&temp_zinit.hc,f,true))
19991 {
19992 return qe_invalid;
19993 }
19994
19995
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 if(s_version < 14)
19996 {
19997 byte temphp;
19998
19999 if(!p_getc(&temphp,f,true))
20000 {
20001 return qe_invalid;
20002 }
20003
20004 temp_zinit.start_heart=temphp;
20005
20006 if(!p_getc(&temphp,f,true))
20007 {
20008 return qe_invalid;
20009 }
20010
20011 temp_zinit.cont_heart=temphp;
20012 }
20013 else
20014 {
20015
2/4
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 58 times.
✗ Branch 3 not taken.
58 if(!p_igetw(&temp_zinit.start_heart,f,true))
20016 {
20017 return qe_invalid;
20018 }
20019
20020
2/4
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 58 times.
✗ Branch 3 not taken.
58 if(!p_igetw(&temp_zinit.cont_heart,f,true))
20021 {
20022 return qe_invalid;
20023 }
20024 }
20025
20026
2/4
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 58 times.
✗ Branch 3 not taken.
58 if(!p_getc(&temp_zinit.hcp,f,true))
20027 {
20028 return qe_invalid;
20029 }
20030
20031
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(s_version >= 14)
20032 {
20033
2/4
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 58 times.
✗ Branch 3 not taken.
58 if(!p_getc(&temp_zinit.hcp_per_hc,f,true))
20034 {
20035 return qe_invalid;
20036 }
20037
20038
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 if(s_version<16) // July 2007
20039 {
20040 if(get_bit(quest_rules,qr_BRANGPICKUP+1))
20041 temp_zinit.hcp_per_hc = 0xFF;
20042
20043 //Dispose of legacy rule
20044 set_bit(quest_rules,qr_BRANGPICKUP+1, 0);
20045 }
20046 58 }
20047
20048
2/2
✓ Branch 0 taken 55 times.
✓ Branch 1 taken 3 times.
58 if(s_version < 29)
20049 {
20050
2/4
✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 55 times.
✗ Branch 3 not taken.
55 if(!p_getc(&padding,f,true))
20051 return qe_invalid;
20052 55 temp_zinit.max_bombs = padding;
20053 55 }
20054
20055
2/4
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 58 times.
✗ Branch 3 not taken.
58 if(!p_getc(&temp_zinit.keys,f,true))
20056 {
20057 return qe_invalid;
20058 }
20059
20060
2/4
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 58 times.
✗ Branch 3 not taken.
58 if(!p_igetw(&temp_zinit.rupies,f,true))
20061 {
20062 return qe_invalid;
20063 }
20064
20065
2/4
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 58 times.
✗ Branch 3 not taken.
58 if(!p_getc(&temp_zinit.triforce,f,true))
20066 {
20067 return qe_invalid;
20068 }
20069
20070
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
58 if(s_version>12 || (Header->zelda_version == 0x211 && Header->build == 18))
20071 {
20072
2/2
✓ Branch 0 taken 3712 times.
✓ Branch 1 taken 58 times.
3770 for(int32_t i=0; i<64; i++)
20073 {
20074
2/4
✓ Branch 0 taken 3712 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3712 times.
3712 if(!p_getc(&temp_zinit.map[i],f,true))
20075 {
20076 return qe_invalid;
20077 }
20078 3712 }
20079
20080
2/2
✓ Branch 0 taken 3712 times.
✓ Branch 1 taken 58 times.
3770 for(int32_t i=0; i<64; i++)
20081 {
20082
2/4
✓ Branch 0 taken 3712 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3712 times.
3712 if(!p_getc(&temp_zinit.compass[i],f,true))
20083 {
20084 return qe_invalid;
20085 }
20086 3712 }
20087 58 }
20088 else
20089 {
20090 for(int32_t i=0; i<32; i++)
20091 {
20092 if(!p_getc(&temp_zinit.map[i],f,true))
20093 {
20094 return qe_invalid;
20095 }
20096 }
20097
20098 for(int32_t i=0; i<32; i++)
20099 {
20100 if(!p_getc(&temp_zinit.compass[i],f,true))
20101 {
20102 return qe_invalid;
20103 }
20104 }
20105 }
20106
20107
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
58 if((Header->zelda_version > 0x192)||
20108 //new only
20109 ((Header->zelda_version == 0x192)&&(Header->build>173)))
20110 {
20111
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
58 if(s_version>12 || (Header->zelda_version == 0x211 && Header->build == 18))
20112 {
20113
2/2
✓ Branch 0 taken 3712 times.
✓ Branch 1 taken 58 times.
3770 for(int32_t i=0; i<64; i++)
20114 {
20115
2/4
✓ Branch 0 taken 3712 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3712 times.
3712 if(!p_getc(&temp_zinit.boss_key[i],f,true))
20116 {
20117 return qe_invalid;
20118 }
20119 3712 }
20120 58 }
20121 else
20122 {
20123 for(int32_t i=0; i<32; i++)
20124 {
20125 if(!p_getc(&temp_zinit.boss_key[i],f,true))
20126 {
20127 return qe_invalid;
20128 }
20129 }
20130 }
20131 58 }
20132
20133
2/2
✓ Branch 0 taken 58 times.
✓ Branch 1 taken 928 times.
986 for(int32_t i=0; i<16; i++)
20134 {
20135
2/4
✓ Branch 0 taken 928 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 928 times.
928 if(!p_getc(&temp_zinit.misc[i],f,true))
20136 {
20137 return qe_invalid;
20138 }
20139 928 }
20140
20141
1/4
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
58 if(s_version < 15) for(int32_t i=0; i<4; i++)
20142 {
20143 if(!p_getc(&sword_hearts[i],f,true))
20144 {
20145 return qe_invalid;
20146 }
20147 }
20148
20149
2/4
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 58 times.
✗ Branch 3 not taken.
58 if(!p_getc(&temp_zinit.last_map,f,true))
20150 {
20151 return qe_invalid;
20152 }
20153
20154
2/4
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 58 times.
✗ Branch 3 not taken.
58 if(!p_getc(&temp_zinit.last_screen,f,true))
20155 {
20156 return qe_invalid;
20157 }
20158
20159
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 if(s_version < 14)
20160 {
20161 byte tempmp;
20162
20163 if(!p_getc(&tempmp,f,true))
20164 {
20165 return qe_invalid;
20166 }
20167
20168 temp_zinit.max_magic=tempmp;
20169
20170 if(!p_getc(&tempmp,f,true))
20171 {
20172 return qe_invalid;
20173 }
20174
20175 temp_zinit.magic=tempmp;
20176 }
20177 else
20178 {
20179
2/4
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 58 times.
✗ Branch 3 not taken.
58 if(!p_igetw(&temp_zinit.max_magic,f,true))
20180 {
20181 return qe_invalid;
20182 }
20183
20184
2/4
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 58 times.
✗ Branch 3 not taken.
58 if(!p_igetw(&temp_zinit.magic,f,true))
20185 {
20186 return qe_invalid;
20187 }
20188 }
20189
20190
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(s_version < 15)
20191 {
20192 if(s_version < 12)
20193 {
20194 temp_zinit.max_magic*=32;
20195 temp_zinit.magic*=32;
20196 }
20197
20198 for(int32_t i=0; i<4; i++)
20199 {
20200 if(!p_getc(&beam_hearts[i],f,true))
20201 {
20202 return qe_invalid;
20203 }
20204 }
20205
20206 if(!p_getc(&beam_percent,f,true))
20207 {
20208 return qe_invalid;
20209 }
20210 }
20211 else
20212 {
20213
2/4
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 58 times.
✗ Branch 3 not taken.
58 if(!p_getc(&temp_zinit.bomb_ratio,f,true))
20214 {
20215 return qe_invalid;
20216 }
20217 }
20218
20219
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(s_version < 15)
20220 {
20221 byte tempbp;
20222
20223 for(int32_t i=0; i<4; i++)
20224 {
20225 if(!(s_version < 14 ? p_getc(&tempbp,f,true) : p_igetw(&tempbp,f,true)))
20226 {
20227 return qe_invalid;
20228 }
20229
20230 beam_power[i]=tempbp;
20231 }
20232
20233 if(!p_getc(&hookshot_links,f,true))
20234 {
20235 return qe_invalid;
20236 }
20237
20238 if(s_version>6)
20239 {
20240 if(!p_getc(&hookshot_length,f,true))
20241 {
20242 return qe_invalid;
20243 }
20244
20245 if(!p_getc(&longshot_links,f,true))
20246 {
20247 return qe_invalid;
20248 }
20249
20250 if(!p_getc(&longshot_length,f,true))
20251 {
20252 return qe_invalid;
20253 }
20254 }
20255 }
20256
20257
2/4
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 58 times.
✗ Branch 3 not taken.
58 if(!p_getc(&temp_zinit.msg_more_x,f,true))
20258 {
20259 return qe_invalid;
20260 }
20261
20262
2/4
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 58 times.
✗ Branch 3 not taken.
58 if(!p_getc(&temp_zinit.msg_more_y,f,true))
20263 {
20264 return qe_invalid;
20265 }
20266
20267
2/4
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 58 times.
✗ Branch 3 not taken.
58 if(!p_getc(&temp_zinit.subscreen,f,true))
20268 {
20269 return qe_invalid;
20270 }
20271
20272 //old only
20273
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
58 if((Header->zelda_version == 0x192)&&(Header->build<174))
20274 {
20275 for(int32_t i=0; i<32; i++)
20276 {
20277 if(!p_getc(&temp_zinit.boss_key[i],f,true))
20278 {
20279 return qe_invalid;
20280 }
20281 }
20282 }
20283
20284
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
58 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>173))) //new only
20285 {
20286
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 if(s_version <= 10)
20287 {
20288 byte tempbyte;
20289
20290 if(!p_getc(&tempbyte,f,true))
20291 {
20292 return qe_invalid;
20293 }
20294
20295 temp_zinit.start_dmap = (word)tempbyte;
20296 }
20297 else
20298 {
20299
2/4
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 58 times.
✗ Branch 3 not taken.
58 if(!p_igetw(&temp_zinit.start_dmap,f,true))
20300 {
20301 return qe_invalid;
20302 }
20303 }
20304
20305
2/4
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 58 times.
✗ Branch 3 not taken.
58 if(!p_getc(&temp_zinit.heroAnimationStyle,f,true))
20306 {
20307 return qe_invalid;
20308 }
20309 58 }
20310
20311
3/4
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 55 times.
✓ Branch 3 taken 3 times.
58 if(s_version>1 && s_version < 29)
20312 {
20313
2/4
✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 55 times.
✗ Branch 3 not taken.
55 if(!p_getc(&padding,f,true))
20314 return qe_invalid;
20315 55 temp_zinit.arrows = padding;
20316
20317
2/4
✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 55 times.
✗ Branch 3 not taken.
55 if(!p_getc(&padding,f,true))
20318 return qe_invalid;
20319 55 temp_zinit.max_arrows = padding;
20320 55 }
20321
20322
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 if(s_version>2)
20323 {
20324
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 if(s_version <= 10)
20325 {
20326 for(int32_t i=0; i<OLDMAXLEVELS; i++)
20327 {
20328 if(!p_getc(&(temp_zinit.level_keys[i]),f,true))
20329 {
20330 return qe_invalid;
20331 }
20332 }
20333 }
20334 else
20335 {
20336
2/2
✓ Branch 0 taken 29696 times.
✓ Branch 1 taken 58 times.
29754 for(int32_t i=0; i<MAXLEVELS; i++)
20337 {
20338
2/4
✓ Branch 0 taken 29696 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29696 times.
✗ Branch 3 not taken.
29696 if(!p_getc(&(temp_zinit.level_keys[i]),f,true))
20339 {
20340 return qe_invalid;
20341 }
20342 29696 }
20343 }
20344 58 }
20345
20346
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(s_version>3)
20347 {
20348
2/4
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 58 times.
✗ Branch 3 not taken.
58 if(!p_igetw(&temp_zinit.ss_grid_x,f,true))
20349 {
20350 return qe_invalid;
20351 }
20352
20353
2/4
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 58 times.
✗ Branch 3 not taken.
58 if(!p_igetw(&temp_zinit.ss_grid_y,f,true))
20354 {
20355 return qe_invalid;
20356 }
20357
20358
2/4
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 58 times.
✗ Branch 3 not taken.
58 if(!p_igetw(&temp_zinit.ss_grid_xofs,f,true))
20359 {
20360 return qe_invalid;
20361 }
20362
20363
2/4
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 58 times.
✗ Branch 3 not taken.
58 if(!p_igetw(&temp_zinit.ss_grid_yofs,f,true))
20364 {
20365 return qe_invalid;
20366 }
20367
20368
2/4
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 58 times.
✗ Branch 3 not taken.
58 if(!p_igetw(&temp_zinit.ss_grid_color,f,true))
20369 {
20370 return qe_invalid;
20371 }
20372
20373
2/4
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 58 times.
✗ Branch 3 not taken.
58 if(!p_igetw(&temp_zinit.ss_bbox_1_color,f,true))
20374 {
20375 return qe_invalid;
20376 }
20377
20378
2/4
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 58 times.
✗ Branch 3 not taken.
58 if(!p_igetw(&temp_zinit.ss_bbox_2_color,f,true))
20379 {
20380 return qe_invalid;
20381 }
20382
20383
2/4
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 58 times.
✗ Branch 3 not taken.
58 if(!p_igetw(&temp_zinit.ss_flags,f,true))
20384 {
20385 return qe_invalid;
20386 }
20387
20388
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 temp_zinit.ss_grid_x=zc_max(temp_zinit.ss_grid_x,1);
20389
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 temp_zinit.ss_grid_y=zc_max(temp_zinit.ss_grid_y,1);
20390 58 }
20391
20392
2/4
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 58 times.
58 if(s_version>4 && s_version<15)
20393 {
20394 if(!p_getc(&moving_fairy_hearts,f,true))
20395 {
20396 return qe_invalid;
20397 }
20398
20399 if(!p_getc(&moving_fairy_heart_percent,f,true))
20400 {
20401 return qe_invalid;
20402 }
20403 }
20404
20405
2/4
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 58 times.
58 if(s_version>5 && s_version < 10)
20406 {
20407 if(!p_getc(&temp,f,true))
20408 {
20409 return qe_invalid;
20410 }
20411
20412 addOldStyleFamily(&temp_zinit, itemsbuf, itype_quiver, temp);
20413 }
20414
20415
2/4
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 58 times.
58 if(s_version>6 && s_version<15)
20416 {
20417 if(!p_getc(&stationary_fairy_hearts,f,true))
20418 {
20419 return qe_invalid;
20420 }
20421
20422 if(!p_getc(&stationary_fairy_heart_percent,f,true))
20423 {
20424 return qe_invalid;
20425 }
20426
20427 if(!p_getc(&moving_fairy_magic,f,true))
20428 {
20429 return qe_invalid;
20430 }
20431
20432 if(!p_getc(&moving_fairy_magic_percent,f,true))
20433 {
20434 return qe_invalid;
20435 }
20436
20437 if(!p_getc(&stationary_fairy_magic,f,true))
20438 {
20439 return qe_invalid;
20440 }
20441
20442 if(!p_getc(&stationary_fairy_magic_percent,f,true))
20443 {
20444 return qe_invalid;
20445 }
20446
20447 if(!p_getc(&blue_potion_hearts,f,true))
20448 {
20449 return qe_invalid;
20450 }
20451
20452 if(!p_getc(&blue_potion_heart_percent,f,true))
20453 {
20454 return qe_invalid;
20455 }
20456
20457 if(!p_getc(&red_potion_hearts,f,true))
20458 {
20459 return qe_invalid;
20460 }
20461
20462 if(!p_getc(&red_potion_heart_percent,f,true))
20463 {
20464 return qe_invalid;
20465 }
20466
20467 if(!p_getc(&blue_potion_magic,f,true))
20468 {
20469 return qe_invalid;
20470 }
20471
20472 if(!p_getc(&blue_potion_magic_percent,f,true))
20473 {
20474 return qe_invalid;
20475 }
20476
20477 if(!p_getc(&red_potion_magic,f,true))
20478 {
20479 return qe_invalid;
20480 }
20481
20482 if(!p_getc(&red_potion_magic_percent,f,true))
20483 {
20484 return qe_invalid;
20485 }
20486 }
20487
20488
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(s_version>6)
20489 {
20490
2/4
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 58 times.
✗ Branch 3 not taken.
58 if(!p_getc(&temp_zinit.subscreen_style,f,true))
20491 {
20492 return qe_invalid;
20493 }
20494 58 }
20495
20496
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(s_version>7)
20497 {
20498
2/4
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 58 times.
✗ Branch 3 not taken.
58 if(!p_getc(&temp_zinit.usecustomsfx,f,true))
20499 {
20500 return qe_invalid;
20501 }
20502 58 }
20503
20504
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(s_version>8)
20505 {
20506
2/4
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 58 times.
✗ Branch 3 not taken.
58 if(!p_igetw(&temp_zinit.max_rupees,f,true))
20507 {
20508 return qe_invalid;
20509 }
20510
20511
2/4
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 58 times.
✗ Branch 3 not taken.
58 if(!p_igetw(&temp_zinit.max_keys,f,true))
20512 {
20513 return qe_invalid;
20514 }
20515 58 }
20516
20517
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(s_version>16)
20518 {
20519
2/4
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 58 times.
✗ Branch 3 not taken.
58 if(!p_getc(&temp_zinit.gravity,f,true))
20520 {
20521 return qe_invalid;
20522 }
20523
20524
2/4
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 58 times.
✗ Branch 3 not taken.
58 if(!p_igetw(&temp_zinit.terminalv,f,true))
20525 {
20526 return qe_invalid;
20527 }
20528
20529
2/4
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 58 times.
✗ Branch 3 not taken.
58 if(!p_getc(&temp_zinit.msg_speed,f,true))
20530 {
20531 return qe_invalid;
20532 }
20533
20534
2/4
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 58 times.
✗ Branch 3 not taken.
58 if(!p_getc(&temp_zinit.transition_type,f,true))
20535 {
20536 return qe_invalid;
20537 }
20538
20539
2/4
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 58 times.
✗ Branch 3 not taken.
58 if(!p_getc(&temp_zinit.jump_hero_layer_threshold,f,true))
20540 {
20541 return qe_invalid;
20542 }
20543 58 }
20544
20545
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(s_version>17)
20546 {
20547
2/4
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 58 times.
✗ Branch 3 not taken.
58 if(!p_getc(&temp_zinit.msg_more_is_offset,f,true))
20548 {
20549 return qe_invalid;
20550 }
20551 58 }
20552
20553 //expaned init data for larger values in 2.55
20554
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 55 times.
58 if ( s_version >= 19 ) //expand init data bombs, sbombs, and arrows to 0xFFFF
20555 {
20556
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_igetw(&temp_zinit.bombs,f,true))
20557 {
20558 return qe_invalid;
20559 }
20560
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_igetw(&temp_zinit.super_bombs,f,true))
20561 {
20562 return qe_invalid;
20563 }
20564
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_igetw(&temp_zinit.max_bombs,f,true))
20565 {
20566 return qe_invalid;
20567 }
20568
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_igetw(&temp_zinit.max_sbombs,f,true))
20569 {
20570 return qe_invalid;
20571 }
20572
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_igetw(&temp_zinit.arrows,f,true))
20573 {
20574 return qe_invalid;
20575 }
20576
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_igetw(&temp_zinit.max_arrows,f,true))
20577 {
20578 return qe_invalid;
20579 }
20580
20581 3 }
20582
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 55 times.
58 if ( s_version >= 20 )
20583 {
20584
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_igetw(&temp_zinit.heroStep,f,true))
20585 {
20586 return qe_invalid;
20587 }
20588 3 }
20589 else
20590 {
20591 55 temp_zinit.heroStep = 150; //1.5 pixels per frame
20592 }
20593
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 55 times.
58 if ( s_version >= 21 )
20594 {
20595
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_igetw(&temp_zinit.subscrSpeed,f,true))
20596 {
20597 return qe_invalid;
20598 }
20599 3 }
20600 else
20601 {
20602 55 temp_zinit.subscrSpeed = 1; //3 pixels per frame
20603 }
20604 //old only
20605
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
58 if((Header->zelda_version == 0x192)&&(Header->build<174))
20606 {
20607 byte items2;
20608
20609 if(!p_getc(&items2,f,true))
20610 {
20611 return qe_invalid;
20612 }
20613
20614 temp_zinit.items[iDinsFire]=(get_bit(&items2, idI_DFIRE)!=0);
20615 temp_zinit.items[iFaroresWind]=(get_bit(&items2, idI_FWIND)!=0);
20616 temp_zinit.items[iNayrusLove]=(get_bit(&items2, idI_NLOVE)!=0);
20617 }
20618
20619
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(Header->zelda_version < 0x193)
20620 {
20621 for(int32_t q=0; q<96; q++)
20622 {
20623 if(!p_getc(&padding,f,true))
20624 {
20625 return qe_invalid;
20626 }
20627 }
20628
20629 //new only
20630 if((Header->zelda_version == 0x192)&&(Header->build>173))
20631 {
20632 if(!p_getc(&padding,f,true))
20633 {
20634 return qe_invalid;
20635 }
20636
20637 if(!p_getc(&padding,f,true))
20638 {
20639 return qe_invalid;
20640 }
20641 }
20642 }
20643 58 }
20644
20645
3/6
✓ Branch 0 taken 58 times.
✓ Branch 1 taken 52 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 58 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
110 if((Header->zelda_version < 0x211)||((Header->zelda_version == 0x211)&&(Header->build<15)))
20646 {
20647 //temp_zinit.shield=i_smallshield;
20648
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 52 times.
52 int32_t sshieldid = getItemID(itemsbuf, itype_shield, i_smallshield);
20649
20650 if(sshieldid != -1)
20651 temp_zinit.items[sshieldid] = true;
20652 }
20653
20654
2/6
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 58 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
58 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<27)))
20655 {
20656 temp_zinit.hc=3;
20657 temp_zinit.start_heart=3;
20658 temp_zinit.cont_heart=3;
20659 temp_zinit.max_bombs=8;
20660 }
20661
20662
2/6
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 58 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
58 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<50)))
20663 {
20664 sword_hearts[0]=0;
20665 sword_hearts[1]=5;
20666 sword_hearts[2]=12;
20667 sword_hearts[3]=21;
20668 }
20669
20670
2/4
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 58 times.
58 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<51)))
20671 {
20672 temp_zinit.last_map=0;
20673 temp_zinit.last_screen=0;
20674 }
20675
20676
2/6
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 58 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
58 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<68)))
20677 {
20678 temp_zinit.max_magic=0;
20679 temp_zinit.magic=0;
20680 set_bit(temp_zinit.misc,idM_DOUBLEMAGIC,0);
20681 }
20682
20683
2/4
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 58 times.
58 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<129)))
20684 {
20685
20686 for(int32_t x=0; x<4; x++)
20687 {
20688 beam_hearts[x]=100;
20689 }
20690
20691 for(int32_t i=0; i<idBP_MAX; i++)
20692 {
20693 set_bit(&beam_percent,i,!get_bit(quest_rules,qr_LENSHINTS+i));
20694 set_bit(quest_rules,qr_LENSHINTS+i,0);
20695 }
20696
20697 for(int32_t x=0; x<4; x++)
20698 {
20699 beam_power[x]=get_bit(quest_rules,qr_HIDECARRIEDITEMS)?50:100;
20700 }
20701
20702 set_bit(quest_rules,qr_HIDECARRIEDITEMS,0);
20703 hookshot_links=100;
20704 temp_zinit.msg_more_x=224;
20705 temp_zinit.msg_more_y=64;
20706 }
20707
20708 // Okay, let's put these legacy values into itemsbuf.
20709
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(s_version < 15)
20710 for(int32_t i=0; i<MAXITEMS; i++)
20711 {
20712 switch(i)
20713 {
20714 case iFairyStill:
20715 itemsbuf[i].misc1 = stationary_fairy_hearts;
20716 itemsbuf[i].misc2 = stationary_fairy_magic;
20717 itemsbuf[i].misc3 = 0;
20718 itemsbuf[i].flags |= stationary_fairy_heart_percent ? ITEM_FLAG1 : 0;
20719 itemsbuf[i].flags |= stationary_fairy_magic_percent ? ITEM_FLAG2 : 0;
20720 break;
20721
20722 case iFairyMoving:
20723 itemsbuf[i].misc1 = moving_fairy_hearts;
20724 itemsbuf[i].misc2 = moving_fairy_magic;
20725 itemsbuf[i].misc3 = 50;
20726 itemsbuf[i].flags |= moving_fairy_heart_percent ? ITEM_FLAG1 : 0;
20727 itemsbuf[i].flags |= moving_fairy_magic_percent ? ITEM_FLAG2 : 0;
20728 break;
20729
20730 case iRPotion:
20731 itemsbuf[i].misc1 = red_potion_hearts;
20732 itemsbuf[i].misc2 = red_potion_magic;
20733 itemsbuf[i].flags |= red_potion_heart_percent ? ITEM_FLAG1 : 0;
20734 itemsbuf[i].flags |= red_potion_magic_percent ? ITEM_FLAG2 : 0;
20735 break;
20736
20737 case iBPotion:
20738 itemsbuf[i].misc1 = blue_potion_hearts;
20739 itemsbuf[i].misc2 = blue_potion_magic;
20740 itemsbuf[i].flags |= blue_potion_heart_percent ? ITEM_FLAG1 : 0;
20741 itemsbuf[i].flags |= blue_potion_magic_percent ? ITEM_FLAG2 : 0;
20742 break;
20743
20744 case iSword:
20745 itemsbuf[i].pickup_hearts = sword_hearts[0];
20746 itemsbuf[i].misc1 = beam_hearts[0];
20747 itemsbuf[i].misc2 = beam_power[0];
20748 // It seems that ITEM_FLAG1 was already added by reset_itembuf()...
20749 itemsbuf[i].flags &= (!get_bit(&beam_percent,0)) ? ~ITEM_FLAG1 : ~0;
20750 break;
20751
20752 case iWSword:
20753 itemsbuf[i].pickup_hearts = sword_hearts[1];
20754 itemsbuf[i].misc1 = beam_hearts[1];
20755 itemsbuf[i].misc2 = beam_power[1];
20756 itemsbuf[i].flags &= (!get_bit(&beam_percent,1)) ? ~ITEM_FLAG1 : ~0;
20757 break;
20758
20759 case iMSword:
20760 itemsbuf[i].pickup_hearts = sword_hearts[2];
20761 itemsbuf[i].misc1 = beam_hearts[2];
20762 itemsbuf[i].misc2 = beam_power[2];
20763 itemsbuf[i].flags &= (!get_bit(&beam_percent,2)) ? ~ITEM_FLAG1 : ~0;
20764 break;
20765
20766 case iXSword:
20767 itemsbuf[i].pickup_hearts = sword_hearts[3];
20768 itemsbuf[i].misc1 = beam_hearts[3];
20769 itemsbuf[i].misc2 = beam_power[3];
20770 itemsbuf[i].flags &= (!get_bit(&beam_percent,3)) ? ~ITEM_FLAG1 : ~0;
20771 break;
20772
20773 case iHookshot:
20774 itemsbuf[i].misc1 = hookshot_length;
20775 itemsbuf[i].misc2 = hookshot_links;
20776 break;
20777
20778 case iLongshot:
20779 itemsbuf[i].misc1 = longshot_length;
20780 itemsbuf[i].misc2 = longshot_links;
20781 break;
20782 }
20783 }
20784
20785
2/6
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 58 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
58 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<168)))
20786 {
20787 //was new subscreen rule
20788 temp_zinit.subscreen=get_bit(quest_rules,qr_FREEFORM)?1:0;
20789 set_bit(quest_rules,qr_FREEFORM,0);
20790 }
20791
20792
2/4
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 58 times.
58 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<185)))
20793 {
20794 temp_zinit.start_dmap=0;
20795 }
20796
20797
2/6
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 58 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
58 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<186)))
20798 {
20799 temp_zinit.heroAnimationStyle=get_bit(quest_rules,qr_BSZELDA)?1:0;
20800 }
20801
20802
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
58 if(s_version < 16 && get_bit(deprecated_rules, qr_COOLSCROLL+1))
20803 {
20804 //addOldStyleFamily(&temp_zinit, itemsbuf, itype_wallet, 4); //is this needed?
20805 temp_zinit.max_rupees=999;
20806 //temp_zinit.rupies=999; //This rule only gave you an invisible max wallet; it did not give you max rupies.
20807 }
20808
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(Header->zelda_version < 0x190) //1.84 bugfix. -Z
20809 {
20810 //temp_zinit.items[iBombBag] = true; //No, this is 30 max bombs!
20811 temp_zinit.max_bombs = 8;
20812 }
20813 // al_trace("About to copy over new init data values for quest made in: %x\n", Header->zelda_version);
20814 //time to ensure that we port all new values properly:
20815
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(Header->zelda_version < 0x250)
20816 {
20817 temp_zinit.max_sbombs = temp_zinit.bomb_ratio > 0 ? ( temp_zinit.max_bombs/temp_zinit.bomb_ratio ) : (temp_zinit.max_bombs/4);
20818 }
20819
20820
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 55 times.
58 if(s_version > 21)
20821 {
20822
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&temp_zinit.hp_per_heart,f,true))
20823 {
20824 return qe_invalid;
20825 }
20826
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&temp_zinit.magic_per_block,f,true))
20827 {
20828 return qe_invalid;
20829 }
20830
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&temp_zinit.hero_damage_multiplier,f,true))
20831 {
20832 return qe_invalid;
20833 }
20834
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&temp_zinit.ene_damage_multiplier,f,true))
20835 {
20836 return qe_invalid;
20837 }
20838 3 }
20839 else
20840 {
20841 55 temp_zinit.hp_per_heart = 16; //HP_PER_HEART, previously hardcoded
20842 55 temp_zinit.magic_per_block = 32; //MAGICPERBLOCK, previously hardcoded
20843 55 temp_zinit.hero_damage_multiplier = 2; //DAMAGE_MULTIPLIER, previously hardcoded
20844 55 temp_zinit.ene_damage_multiplier = 4; //(HP_PER_HEART/4), previously hardcoded
20845 }
20846
20847
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 55 times.
58 if(s_version > 22)
20848 {
20849
2/2
✓ Branch 0 taken 75 times.
✓ Branch 1 taken 3 times.
78 for(int32_t q = 0; q < 25; ++q)
20850 {
20851
2/4
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 75 times.
75 if(!p_igetw(&temp_zinit.scrcnt[q],f,true))
20852 {
20853 return qe_invalid;
20854 }
20855 75 }
20856
2/2
✓ Branch 0 taken 75 times.
✓ Branch 1 taken 3 times.
78 for(int32_t q = 0; q < 25; ++q)
20857 {
20858
2/4
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 75 times.
75 if(!p_igetw(&temp_zinit.scrmaxcnt[q],f,true))
20859 {
20860 return qe_invalid;
20861 }
20862 75 }
20863 3 }
20864 else
20865 {
20866
2/2
✓ Branch 0 taken 1375 times.
✓ Branch 1 taken 55 times.
1430 for(int32_t q = 0; q < 25; ++q)
20867 {
20868 1375 temp_zinit.scrcnt[q] = 0;
20869 1375 temp_zinit.scrmaxcnt[q] = 0;
20870 1375 }
20871 }
20872
20873
20874
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 55 times.
58 if(s_version > 23)
20875 {
20876
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&temp_zinit.dither_type,f,true))
20877 {
20878 return qe_invalid;
20879 }
20880
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&temp_zinit.dither_arg,f,true))
20881 {
20882 return qe_invalid;
20883 }
20884
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&temp_zinit.dither_percent,f,true))
20885 {
20886 return qe_invalid;
20887 }
20888
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&temp_zinit.def_lightrad,f,true))
20889 {
20890 return qe_invalid;
20891 }
20892
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&temp_zinit.transdark_percent,f,true))
20893 {
20894 return qe_invalid;
20895 }
20896 3 }
20897 else
20898 {
20899 55 temp_zinit.dither_type = 0;
20900 55 temp_zinit.dither_arg = 0;
20901 55 temp_zinit.dither_percent = 20;
20902 55 temp_zinit.def_lightrad = 24;
20903 55 temp_zinit.transdark_percent = 0;
20904 }
20905
20906
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 55 times.
58 if(s_version > 24)
20907 {
20908
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&temp_zinit.darkcol,f,true))
20909 {
20910 return qe_invalid;
20911 }
20912 3 }
20913 else
20914 {
20915 55 temp_zinit.darkcol = BLACK;
20916 }
20917
20918
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 55 times.
58 if(s_version > 25)
20919 {
20920
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_igetl(&temp_zinit.gravity2,f,true))
20921 {
20922 return qe_invalid;
20923 }
20924
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_igetl(&temp_zinit.swimgravity,f,true))
20925 {
20926 return qe_invalid;
20927 }
20928 3 }
20929 else
20930 {
20931 55 temp_zinit.gravity2 = temp_zinit.gravity*100;
20932 55 temp_zinit.swimgravity = 5;
20933 }
20934
20935
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 55 times.
58 if(s_version > 26)
20936 {
20937
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_igetw(&temp_zinit.heroSideswimUpStep,f,true))
20938 {
20939 return qe_invalid;
20940 }
20941
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_igetw(&temp_zinit.heroSideswimSideStep,f,true))
20942 {
20943 return qe_invalid;
20944 }
20945
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_igetw(&temp_zinit.heroSideswimDownStep,f,true))
20946 {
20947 return qe_invalid;
20948 }
20949 3 }
20950 else
20951 {
20952 55 temp_zinit.heroSideswimUpStep = 150;
20953 55 temp_zinit.heroSideswimSideStep = 100;
20954 55 temp_zinit.heroSideswimDownStep = 75;
20955 }
20956
20957
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 55 times.
58 if(s_version > 27)
20958 {
20959
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_igetl(&temp_zinit.exitWaterJump,f,true))
20960 {
20961 return qe_invalid;
20962 }
20963 3 }
20964 else
20965 {
20966 55 temp_zinit.exitWaterJump = 0;
20967 }
20968
20969
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 55 times.
58 if(s_version > 29)
20970 {
20971
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_igetl(&temp_zinit.bunny_ltm,f,true))
20972 {
20973 return qe_invalid;
20974 }
20975 3 }
20976 else
20977 {
20978 55 temp_zinit.bunny_ltm = 0;
20979 }
20980
20981
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 55 times.
58 if(s_version > 30)
20982 {
20983
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&temp_zinit.switchhookstyle,f,true))
20984 {
20985 return qe_invalid;
20986 }
20987 3 }
20988 else
20989 {
20990 55 temp_zinit.switchhookstyle = 1;
20991 }
20992
20993
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 55 times.
58 if(s_version > 31)
20994 {
20995
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&temp_zinit.magicdrainrate,f,true))
20996 {
20997 return qe_invalid;
20998 }
20999 3 }
21000 else
21001 {
21002
1/2
✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
55 temp_zinit.magicdrainrate = (get_bit(temp_zinit.misc,idM_DOUBLEMAGIC) ? 1 : 2);
21003
1/2
✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
55 set_bit(temp_zinit.misc,idM_DOUBLEMAGIC,0);
21004 }
21005
21006
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 temp_zinit.clear_genscript();
21007
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 57 times.
58 if(s_version > 32)
21008 {
21009 1 word numgenscript = 0;
21010
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 if(!p_igetw(&numgenscript,f,true))
21011 return qe_invalid;
21012
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
2 for(auto q = 1; q < numgenscript; ++q)
21013 {
21014
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 if(!p_getc(&padding,f,true))
21015 return qe_invalid;
21016
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!(padding&2))
21017 continue;
21018 1 temp_zinit.gen_doscript[q] = padding&1;
21019
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 if(!p_igetw(&temp_zinit.gen_exitState[q],f,true))
21020 return qe_invalid;
21021
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 if(!p_igetw(&temp_zinit.gen_reloadState[q],f,true))
21022 return qe_invalid;
21023
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 8 times.
9 for(auto p = 0; p < 8; ++p)
21024
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
8 if(!p_igetl(&temp_zinit.gen_initd[q][p],f,true))
21025 return qe_invalid;
21026
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 if(!p_igetl(&temp_zinit.gen_dataSize[q],f,true))
21027 return qe_invalid;
21028
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 if(!p_getlvec<int32_t>(&temp_zinit.gen_data[q],f,true))
21029 return qe_invalid;
21030
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 if(!p_igetl(&temp_zinit.gen_eventstate[q],f,true))
21031 return qe_invalid;
21032 1 }
21033 1 }
21034
21035
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(keepdata==true)
21036 {
21037
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 zinit = temp_zinit;
21038
21039
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 if(zinit.heroAnimationStyle==las_zelda3slow)
21040 {
21041 hero_animation_speed=2;
21042 }
21043 else
21044 {
21045 58 hero_animation_speed=1;
21046 }
21047 58 }
21048
21049 58 return 0;
21050 278 }
21051
21052 /*
21053 void setupitemdropsets()
21054 {
21055 for(int32_t i=0; i<isMAX; i++)
21056 {
21057 memcpy(&item_drop_sets[i], &default_item_drop_sets[i], sizeof(item_drop_object));
21058 }
21059 }
21060 */
21061
21062 58 int32_t readitemdropsets(PACKFILE *f, int32_t version, word build, bool keepdata)
21063 {
21064 58 build=build; // here to prevent compiler warnings
21065 dword dummy_dword;
21066 58 word item_drop_sets_to_read=0;
21067 item_drop_object tempitemdrop;
21068 58 word s_version=0, s_cversion=0;
21069
21070
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 if(keepdata)
21071 {
21072
2/2
✓ Branch 0 taken 14848 times.
✓ Branch 1 taken 58 times.
14906 for(int32_t i=0; i<MAXITEMDROPSETS; i++)
21073 {
21074 14848 memset(&item_drop_sets[i], 0, sizeof(item_drop_object));
21075 14848 }
21076 58 }
21077
21078
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(version > 0x192)
21079 {
21080 58 item_drop_sets_to_read=0;
21081
21082 //section version info
21083
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(!p_igetw(&s_version,f,true))
21084 {
21085 return qe_invalid;
21086 }
21087
21088 58 FFCore.quest_format[vItemDropsets] = s_version;
21089
21090 //al_trace("Item drop sets version %d\n", s_version);
21091
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(!p_igetw(&s_cversion,f,true))
21092 {
21093 return qe_invalid;
21094 }
21095
21096 //section size
21097
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(!p_igetl(&dummy_dword,f,true))
21098 {
21099 return qe_invalid;
21100 }
21101
21102 //finally... section data
21103
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(!p_igetw(&item_drop_sets_to_read,f,true))
21104 {
21105 return qe_invalid;
21106 }
21107 58 }
21108 else
21109 {
21110 if(keepdata==true)
21111 {
21112 init_item_drop_sets();
21113 }
21114 }
21115
21116
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 if(s_version>=1)
21117 {
21118
2/2
✓ Branch 0 taken 1167 times.
✓ Branch 1 taken 58 times.
1225 for(int32_t i=0; i<item_drop_sets_to_read; i++)
21119 {
21120
1/2
✓ Branch 0 taken 1167 times.
✗ Branch 1 not taken.
1167 if(!pfread(tempitemdrop.name,sizeof(tempitemdrop.name),f,true))
21121 {
21122 return qe_invalid;
21123 }
21124
21125
2/2
✓ Branch 0 taken 11670 times.
✓ Branch 1 taken 1167 times.
12837 for(int32_t j=0; j<10; ++j)
21126 {
21127
1/2
✓ Branch 0 taken 11670 times.
✗ Branch 1 not taken.
11670 if(!p_igetw(&tempitemdrop.item[j],f,true))
21128 {
21129 return qe_invalid;
21130 }
21131 11670 }
21132
21133
2/2
✓ Branch 0 taken 12837 times.
✓ Branch 1 taken 1167 times.
14004 for(int32_t j=0; j<11; ++j)
21134 {
21135
1/2
✓ Branch 0 taken 12837 times.
✗ Branch 1 not taken.
12837 if(!p_igetw(&tempitemdrop.chance[j],f,true))
21136 {
21137 return qe_invalid;
21138 }
21139 12837 }
21140
21141 // Dec 2008: Addition of the 'Tall Grass' set, #12,
21142 // overrides the quest's set #12.
21143
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1167 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1167 if(s_version<2 && i==12)
21144 continue;
21145
21146 // Deprecated: qr_NOCLOCKS and qr_ALLOW10RUPEEDROPS
21147
1/4
✓ Branch 0 taken 1167 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1167 if(s_version<2) for(int32_t j=0; j<10; ++j)
21148 {
21149 int32_t it = tempitemdrop.item[j];
21150
21151 if((itemsbuf[it].family == itype_rupee
21152 && ((itemsbuf[it].amount)&0xFFF) == 10)
21153 && !get_bit(deprecated_rules, qr_ALLOW10RUPEEDROPS_DEP))
21154 {
21155 tempitemdrop.chance[j+1]=0;
21156 }
21157 else if(itemsbuf[it].family == itype_clock && get_bit(deprecated_rules, qr_NOCLOCKS_DEP))
21158 {
21159 tempitemdrop.chance[j+1]=0;
21160 }
21161
21162 // From Sept 2007 to Dec 2008, non-gameplay items were prohibited.
21163 if(itemsbuf[it].family == itype_misc)
21164 {
21165 // If a non-gameplay item was selected, then item drop was aborted.
21166 // Reflect this by increasing the 'Nothing' chance accordingly.
21167 tempitemdrop.chance[0]+=tempitemdrop.chance[j+1];
21168 tempitemdrop.chance[j+1]=0;
21169 }
21170 }
21171
21172
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1167 times.
1167 if(keepdata)
21173 {
21174 1167 memcpy(&item_drop_sets[i], &tempitemdrop, sizeof(item_drop_object));
21175 1167 }
21176 1167 }
21177 58 }
21178
21179 58 return 0;
21180 58 }
21181
21182 58 int32_t readfavorites(PACKFILE *f, int32_t, word, bool keepdata)
21183 {
21184 int32_t temp_num;
21185 dword dummy_dword;
21186 word num_favorite_combos;
21187 word num_favorite_combo_aliases;
21188 58 word s_version=0, s_cversion=0;
21189
21190 //section version info
21191
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 if(!p_igetw(&s_version,f,true))
21192 {
21193 return qe_invalid;
21194 }
21195
21196 58 FFCore.quest_format[vFavourites] = s_version;
21197
21198
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(!p_igetw(&s_cversion,f,true))
21199 {
21200 return qe_invalid;
21201 }
21202
21203 //section size
21204
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(!p_igetl(&dummy_dword,f,true))
21205 {
21206 return qe_invalid;
21207 }
21208
21209 //finally... section data
21210
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(!p_igetw(&num_favorite_combos,f,true))
21211 {
21212 return qe_invalid;
21213 }
21214
21215
2/2
✓ Branch 0 taken 5800 times.
✓ Branch 1 taken 58 times.
5858 for(int32_t i=0; i<num_favorite_combos; i++)
21216 {
21217
1/2
✓ Branch 0 taken 5800 times.
✗ Branch 1 not taken.
5800 if(!p_igetl(&temp_num,f,true))
21218 {
21219 return qe_invalid;
21220 }
21221
21222
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5800 times.
5800 if(keepdata)
21223 {
21224 5800 favorite_combos[i]=temp_num;
21225 5800 }
21226 5800 }
21227
21228
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(!p_igetw(&num_favorite_combo_aliases,f,true))
21229 {
21230 return qe_invalid;
21231 }
21232
21233
2/2
✓ Branch 0 taken 5800 times.
✓ Branch 1 taken 58 times.
5858 for(int32_t i=0; i<num_favorite_combo_aliases; i++)
21234 {
21235
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5800 times.
5800 if(!p_igetl(&temp_num,f,true))
21236 {
21237 return qe_invalid;
21238 }
21239
21240
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5800 times.
5800 if(keepdata)
21241 {
21242 5800 favorite_comboaliases[i]=temp_num;
21243 5800 }
21244 5800 }
21245
21246 58 return 0;
21247 58 }
21248
21249 /*
21250 switch (ret) {
21251 case 0:
21252 break;
21253
21254 case qe_invalid:
21255 goto invalid;
21256 break;
21257 default:
21258 pack_fclose(f);
21259 if(!oldquest)
21260 delete_file(tmpfilename);
21261 return ret;
21262 break;
21263 }
21264 */
21265
21266 const char *skip_text[skip_max]=
21267 {
21268 "skip_header", "skip_rules", "skip_strings", "skip_misc",
21269 "skip_tiles", "skip_combos", "skip_comboaliases", "skip_csets",
21270 "skip_maps", "skip_dmaps", "skip_doors", "skip_items",
21271 "skip_weapons", "skip_colors", "skip_icons", "skip_initdata",
21272 "skip_guys", "skip_herosprites", "skip_subscreens", "skip_ffscript",
21273 "skip_sfx", "skip_midis", "skip_cheats", "skip_itemdropsets",
21274 "skip_favorites"
21275 };
21276
21277
21278 void port250QuestRules(){
21279
21280 portCandleRules(); //Candle
21281 portBombRules();
21282
21283 }
21284
21285 void portCandleRules()
21286 {
21287 bool hurtshero = get_bit(quest_rules,qr_FIREPROOFHERO);
21288 //itemdata itemsbuf;
21289 for ( int32_t q = 0; q < MAXITEMS; q++ )
21290 {
21291 if ( itemsbuf[q].family == itype_candle )
21292 {
21293 if ( hurtshero ) itemsbuf[q].flags |= ITEM_FLAG2;
21294 else itemsbuf[q].flags &= ~ ITEM_FLAG2;
21295 }
21296 }
21297 }
21298
21299 void portBombRules()
21300 {
21301 bool hurtshero = get_bit(quest_rules,qr_OUCHBOMBS);
21302 //itemdata itemsbuf;
21303 for ( int32_t q = 0; q < MAXITEMS; q++ )
21304 {
21305 if ( itemsbuf[q].family == itype_bomb )
21306 {
21307 if ( hurtshero ) itemsbuf[q].flags |= ITEM_FLAG2;
21308 else itemsbuf[q].flags &= ~ ITEM_FLAG2;
21309 }
21310 }
21311
21312 }
21313
21314 //Internal function for loadquest wrapper
21315 58 int32_t _lq_int(const char *filename, zquestheader *Header, miscQdata *Misc, zctune *tunes, bool show_progress, bool compressed, bool encrypted, bool keepall, const byte *skip_flags, byte printmetadata)
21316 {
21317 58 DMapEditorLastMaptileUsed = 0;
21318 58 combosread=false;
21319 58 mapsread=false;
21320 58 fixffcs=false;
21321
21322
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
58 if(get_debug()&&(key[KEY_LSHIFT]||key[KEY_RSHIFT]))
21323 {
21324 keepall=false;
21325 jwin_alert("Load Quest","Data retention disabled.",NULL,NULL,"OK",NULL,13,27,lfont);
21326 }
21327
21328 // show_progress=true;
21329 char tmpfilename[L_tmpnam];
21330 58 temp_name(tmpfilename);
21331 // char percent_done[30];
21332 58 bool catchup=false;
21333 byte tempbyte;
21334 58 word old_map_count=map_count;
21335
21336 58 byte old_quest_rules[QUESTRULES_NEW_SIZE] = {0};
21337 58 byte old_extra_rules[EXTRARULES_SIZE] = {0};
21338 58 byte old_midi_flags[MIDIFLAGS_SIZE] = {0};
21339
21340
2/4
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 58 times.
58 if(keepall==false||get_bit(skip_flags, skip_rules))
21341 {
21342 memcpy(old_quest_rules, quest_rules, QUESTRULES_NEW_SIZE);
21343 memcpy(old_extra_rules, extra_rules, EXTRARULES_SIZE);
21344 }
21345
21346 58 memset(quest_rules, 0, QUESTRULES_NEW_SIZE); //clear here to prevent any kind of carryover -Z
21347 // memset(extra_rules, 0, EXTRARULES_SIZE); //clear here to prevent any kind of carryover -Z
21348
21349
2/4
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 58 times.
58 if(keepall==false||get_bit(skip_flags, skip_midis))
21350 {
21351 memcpy(old_midi_flags, midi_flags, MIDIFLAGS_SIZE);
21352 }
21353
21354
21355
2/4
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 58 times.
58 if(keepall&&!get_bit(skip_flags, skip_ffscript))
21356 {
21357 58 zScript.clear();
21358 58 globalmap.clear();
21359 58 genericmap.clear();
21360 58 ffcmap.clear();
21361 58 itemmap.clear();
21362 58 npcmap.clear();
21363 58 ewpnmap.clear();
21364 58 lwpnmap.clear();
21365 58 playermap.clear();
21366 58 dmapmap.clear();
21367 58 screenmap.clear();
21368 58 itemspritemap.clear();
21369 58 comboscriptmap.clear();
21370
21371
2/2
✓ Branch 0 taken 29638 times.
✓ Branch 1 taken 58 times.
29696 for(int32_t i=0; i<NUMSCRIPTFFC-1; i++)
21372 {
21373 29638 ffcmap[i].clear();
21374 29638 }
21375
21376 58 globalmap[0].slotname = "Slot 1:";
21377 58 globalmap[0].scriptname = "~Init";
21378 58 globalmap[0].update();
21379
21380
2/2
✓ Branch 0 taken 406 times.
✓ Branch 1 taken 58 times.
464 for(int32_t i=1; i<NUMSCRIPTGLOBAL; i++)
21381 {
21382 406 globalmap[i].clear();
21383 406 }
21384
21385
2/2
✓ Branch 0 taken 14790 times.
✓ Branch 1 taken 58 times.
14848 for(int32_t i=0; i<NUMSCRIPTITEM-1; i++)
21386 {
21387 14790 itemmap[i].clear();
21388 14790 }
21389
21390 //new script types -- prevent carrying over to a quest that you load after reading them
21391 //e.g., a quest has an npc script, and you make a blank quest, that now believes that it has an npc script, too!
21392
2/2
✓ Branch 0 taken 14790 times.
✓ Branch 1 taken 58 times.
14848 for(int32_t i=0; i<NUMSCRIPTGUYS-1; i++)
21393 {
21394 14790 npcmap[i].clear();
21395 14790 }
21396
2/2
✓ Branch 0 taken 14790 times.
✓ Branch 1 taken 58 times.
14848 for(int32_t i=0; i<NUMSCRIPTWEAPONS-1; i++)
21397 {
21398 14790 lwpnmap[i].clear();
21399 14790 }
21400
2/2
✓ Branch 0 taken 14790 times.
✓ Branch 1 taken 58 times.
14848 for(int32_t i=0; i<NUMSCRIPTWEAPONS-1; i++)
21401 {
21402 14790 ewpnmap[i].clear();
21403 14790 }
21404
2/2
✓ Branch 0 taken 232 times.
✓ Branch 1 taken 58 times.
290 for(int32_t i=0; i<NUMSCRIPTPLAYER-1; i++)
21405 {
21406 232 playermap[i].clear();
21407 232 }
21408
2/2
✓ Branch 0 taken 14790 times.
✓ Branch 1 taken 58 times.
14848 for(int32_t i=0; i<NUMSCRIPTSDMAP-1; i++)
21409 {
21410 14790 dmapmap[i].clear();
21411 14790 }
21412
2/2
✓ Branch 0 taken 14790 times.
✓ Branch 1 taken 58 times.
14848 for(int32_t i=0; i<NUMSCRIPTSCREEN-1; i++)
21413 {
21414 14790 screenmap[i].clear();
21415 14790 }
21416
2/2
✓ Branch 0 taken 14790 times.
✓ Branch 1 taken 58 times.
14848 for(int32_t i=0; i<NUMSCRIPTSITEMSPRITE-1; i++)
21417 {
21418 14790 itemspritemap[i].clear();
21419 14790 }
21420
2/2
✓ Branch 0 taken 29638 times.
✓ Branch 1 taken 58 times.
29696 for(int32_t i=0; i<NUMSCRIPTSCOMBODATA-1; i++)
21421 {
21422 29638 comboscriptmap[i].clear();
21423 29638 }
21424
2/2
✓ Branch 0 taken 29638 times.
✓ Branch 1 taken 58 times.
29696 for(int32_t i=0; i<NUMSCRIPTSGENERIC-1; i++)
21425 {
21426 29638 genericmap[i].clear();
21427 29638 }
21428
21429 58 reset_scripts();
21430 58 }
21431
21432 zquestheader tempheader;
21433 58 memset(&tempheader, 0, sizeof(zquestheader));
21434 58 zinfo tempzi;
21435 58 tempzi.clear();
21436 58 load_tmp_zi = &tempzi;
21437
21438 // oldquest flag is set when an unencrypted qst file is suspected.
21439 58 bool oldquest = false;
21440 58 int32_t open_error=0;
21441 char deletefilename[1024];
21442 58 PACKFILE *f=open_quest_file(&open_error, filename, deletefilename, compressed, encrypted, show_progress);
21443
21444
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 if(!f)
21445 return open_error;
21446 char zinfofilename[2048];
21447 58 replace_extension(zinfofilename, filename, "zinfo", 2047);
21448 58 int32_t ret=0;
21449
21450 //header
21451 58 box_out("Reading Header...");
21452 58 ret=readheader(f, &tempheader, true, printmetadata);
21453
1/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 58 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
58 checkstatus(ret);
21454 58 box_out("okay.");
21455 58 box_eol();
21456
21457
2/2
✓ Branch 0 taken 55 times.
✓ Branch 1 taken 3 times.
58 if(read_zinfo)
21458 {
21459 3 box_out("Reading ZInfo - ");
21460
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 box_out(read_ext_zinfo ? "External..." : "Internal...");
21461
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(read_ext_zinfo)
21462 {
21463 PACKFILE *inf=pack_fopen_password(zinfofilename, F_READ, "");
21464 ret=readzinfo(inf, tempzi, tempheader);
21465 if(inf) pack_fclose(inf);
21466 checkstatus(ret);
21467 }
21468 else
21469 {
21470 3 ret=readzinfo(f, tempzi, tempheader);
21471
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
3 checkstatus(ret);
21472 }
21473 3 box_out("okay.");
21474 3 box_eol();
21475 3 }
21476
21477
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(tempheader.zelda_version>=0x193)
21478 {
21479 dword section_id;
21480
21481 //section id
21482
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(!p_mgetl(&section_id,f,true))
21483 {
21484 return qe_invalid;
21485 }
21486
21487
2/2
✓ Branch 0 taken 1392 times.
✓ Branch 1 taken 58 times.
1450 while(!pack_feof(f))
21488 {
21489
24/25
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
✓ Branch 2 taken 58 times.
✓ Branch 3 taken 58 times.
✓ Branch 4 taken 58 times.
✓ Branch 5 taken 58 times.
✓ Branch 6 taken 58 times.
✓ Branch 7 taken 58 times.
✓ Branch 8 taken 58 times.
✓ Branch 9 taken 58 times.
✓ Branch 10 taken 58 times.
✓ Branch 11 taken 58 times.
✓ Branch 12 taken 58 times.
✓ Branch 13 taken 58 times.
✓ Branch 14 taken 58 times.
✓ Branch 15 taken 58 times.
✓ Branch 16 taken 58 times.
✓ Branch 17 taken 58 times.
✓ Branch 18 taken 58 times.
✓ Branch 19 taken 58 times.
✓ Branch 20 taken 58 times.
✓ Branch 21 taken 58 times.
✓ Branch 22 taken 58 times.
✓ Branch 23 taken 58 times.
✓ Branch 24 taken 58 times.
1392 switch(section_id)
21490 {
21491 case ID_RULES:
21492
21493 //rules
21494
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(catchup)
21495 {
21496 box_out("found.");
21497 box_eol();
21498 catchup=false;
21499 }
21500
21501 58 box_out("Reading Rules...");
21502
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 ret=readrules(f, &tempheader, keepall&&!get_bit(skip_flags, skip_rules));
21503
1/5
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
58 checkstatus(ret);
21504 58 box_out("okay.");
21505 58 box_eol();
21506 58 break;
21507
21508 case ID_STRINGS:
21509
21510 //strings
21511
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(catchup)
21512 {
21513 box_out("found.");
21514 box_eol();
21515 catchup=false;
21516 }
21517
21518 58 box_out("Reading Strings...");
21519
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 ret=readstrings(f, &tempheader, keepall&&!get_bit(skip_flags, skip_strings));
21520
1/5
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
58 checkstatus(ret);
21521 58 box_out("okay.");
21522 58 box_eol();
21523 58 break;
21524
21525 case ID_MISC:
21526
21527 //misc data
21528
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(catchup)
21529 {
21530 box_out("found.");
21531 box_eol();
21532 catchup=false;
21533 }
21534
21535 58 box_out("Reading Misc. Data...");
21536
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 ret=readmisc(f, &tempheader, Misc, keepall&&!get_bit(skip_flags, skip_misc));
21537
1/5
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
58 checkstatus(ret);
21538 58 box_out("okay.");
21539 58 box_eol();
21540 58 break;
21541
21542 case ID_TILES:
21543
21544 //tiles
21545
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(catchup)
21546 {
21547 box_out("found.");
21548 box_eol();
21549 catchup=false;
21550 }
21551
21552 58 box_out("Reading Tiles...");
21553
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 ret=readtiles(f, newtilebuf, &tempheader, tempheader.zelda_version, tempheader.build, 0, NEWMAXTILES, false, keepall&&!get_bit(skip_flags, skip_tiles));
21554
1/5
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
58 checkstatus(ret);
21555 58 box_out("okay.");
21556 58 box_eol();
21557 58 break;
21558
21559 case ID_COMBOS:
21560
21561 //combos
21562
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(catchup)
21563 {
21564 box_out("found.");
21565 box_eol();
21566 catchup=false;
21567 }
21568
21569 58 box_out("Reading Combos...");
21570
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 ret=readcombos(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXCOMBOS, keepall&&!get_bit(skip_flags, skip_combos));
21571 58 combosread=true;
21572
1/5
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
58 checkstatus(ret);
21573 58 box_out("okay.");
21574 58 box_eol();
21575 58 break;
21576
21577 case ID_COMBOALIASES:
21578
21579 //combo aliases
21580
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(catchup)
21581 {
21582 box_out("found.");
21583 box_eol();
21584 catchup=false;
21585 }
21586
21587 58 box_out("Reading Combo Aliases...");
21588
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 ret=readcomboaliases(f, &tempheader, tempheader.zelda_version, tempheader.build, keepall&&!get_bit(skip_flags, skip_comboaliases));
21589
1/5
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
58 checkstatus(ret);
21590 58 box_out("okay.");
21591 58 box_eol();
21592 58 break;
21593
21594 case ID_CSETS:
21595
21596 //color data
21597
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(catchup)
21598 {
21599 box_out("found.");
21600 box_eol();
21601 catchup=false;
21602 }
21603
21604 58 box_out("Reading Color Data...");
21605
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 ret=readcolordata(f, Misc, tempheader.zelda_version, tempheader.build, 0, newerpdTOTAL, keepall&&!get_bit(skip_flags, skip_csets));
21606
1/5
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
58 checkstatus(ret);
21607 58 box_out("okay.");
21608 58 box_eol();
21609 58 break;
21610
21611 case ID_MAPS:
21612
21613 //maps
21614
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(catchup)
21615 {
21616 box_out("found.");
21617 box_eol();
21618 catchup=false;
21619 }
21620
21621 58 box_out("Reading Maps...");
21622
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 ret=readmaps(f, &tempheader, keepall&&!get_bit(skip_flags, skip_maps));
21623 58 mapsread=true;
21624
1/5
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
58 checkstatus(ret);
21625 58 box_out("okay.");
21626 58 box_eol();
21627 58 break;
21628
21629 case ID_DMAPS:
21630
21631 //dmaps
21632
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(catchup)
21633 {
21634 box_out("found.");
21635 box_eol();
21636 catchup=false;
21637 }
21638
21639 58 box_out("Reading DMaps...");
21640
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 ret=readdmaps(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXDMAPS, keepall&&!get_bit(skip_flags, skip_dmaps));
21641
1/5
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
58 checkstatus(ret);
21642 58 box_out("okay.");
21643 58 box_eol();
21644 58 break;
21645
21646 case ID_DOORS:
21647
21648 //door combo sets
21649
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(catchup)
21650 {
21651 box_out("found.");
21652 box_eol();
21653 catchup=false;
21654 }
21655
21656 58 box_out("Reading Doors...");
21657
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 ret=readdoorcombosets(f, &tempheader, keepall&&!get_bit(skip_flags, skip_doors));
21658
1/5
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
58 checkstatus(ret);
21659 58 box_out("okay.");
21660 58 box_eol();
21661 58 break;
21662
21663 case ID_ITEMS:
21664
21665 //items
21666
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(catchup)
21667 {
21668 box_out("found.");
21669 box_eol();
21670 catchup=false;
21671 }
21672
21673 58 box_out("Reading Items...");
21674
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 ret=readitems(f, tempheader.zelda_version, tempheader.build, keepall&&!get_bit(skip_flags, skip_items));
21675
1/5
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
58 checkstatus(ret);
21676
21677 58 box_out("okay.");
21678 58 box_eol();
21679 58 break;
21680
21681 case ID_WEAPONS:
21682
21683 //weapons
21684
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(catchup)
21685 {
21686 box_out("found.");
21687 box_eol();
21688 catchup=false;
21689 }
21690
21691 58 box_out("Reading Weapons...");
21692
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 ret=readweapons(f, &tempheader, keepall&&!get_bit(skip_flags, skip_weapons));
21693
1/5
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
58 checkstatus(ret);
21694 58 box_out("okay.");
21695 58 box_eol();
21696 58 break;
21697
21698 case ID_COLORS:
21699
21700 //misc. colors
21701
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(catchup)
21702 {
21703 box_out("found.");
21704 box_eol();
21705 catchup=false;
21706 }
21707
21708 58 box_out("Reading Misc. Colors...");
21709
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 ret=readmisccolors(f, &tempheader, Misc, keepall&&!get_bit(skip_flags, skip_colors));
21710
1/5
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
58 checkstatus(ret);
21711 58 box_out("okay.");
21712 58 box_eol();
21713 58 break;
21714
21715 case ID_ICONS:
21716
21717 //game icons
21718
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(catchup)
21719 {
21720 box_out("found.");
21721 box_eol();
21722 catchup=false;
21723 }
21724
21725 58 box_out("Reading Game Icons...");
21726
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 ret=readgameicons(f, &tempheader, Misc, keepall&&!get_bit(skip_flags, skip_icons));
21727
1/5
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
58 checkstatus(ret);
21728 58 box_out("okay.");
21729 58 box_eol();
21730 58 break;
21731
21732 case ID_INITDATA:
21733
21734 //initialization data
21735
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(catchup)
21736 {
21737 box_out("found.");
21738 box_eol();
21739 catchup=false;
21740 }
21741
21742 58 box_out("Reading Init. Data...");
21743
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 ret=readinitdata(f, &tempheader, keepall&&!get_bit(skip_flags, skip_initdata));
21744
1/5
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
58 checkstatus(ret);
21745 58 box_out("okay.");
21746 58 box_eol();
21747
21748
2/4
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 58 times.
58 if(keepall&&!get_bit(skip_flags, skip_subscreens))
21749 {
21750
2/2
✓ Branch 0 taken 49 times.
✓ Branch 1 taken 9 times.
58 if(zinit.subscreen!=ssdtMAX) //not using custom subscreens
21751 {
21752 9 setupsubscreens();
21753
21754
2/2
✓ Branch 0 taken 4608 times.
✓ Branch 1 taken 9 times.
4617 for(int32_t i=0; i<MAXDMAPS; ++i)
21755 {
21756 4608 int32_t type=DMaps[i].type&dmfTYPE;
21757
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 4599 times.
4608 DMaps[i].active_subscreen=(type == dmOVERW || type == dmBSOVERW)?0:1;
21758 4608 DMaps[i].passive_subscreen=(get_bit(quest_rules,qr_ENABLEMAGIC))?0:1;
21759 4608 }
21760 9 }
21761 58 }
21762
21763
2/4
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 58 times.
58 if(keepall&&!get_bit(skip_flags, skip_sfx))
21764 {
21765 58 setupsfx();
21766 58 }
21767
21768
2/4
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 58 times.
58 if(keepall&&!get_bit(skip_flags, skip_itemdropsets))
21769 {
21770 58 init_item_drop_sets();
21771 58 }
21772
21773
2/4
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 58 times.
58 if(keepall&&!get_bit(skip_flags, skip_favorites))
21774 {
21775 58 init_favorites();
21776 58 }
21777
21778 58 break;
21779
21780 case ID_GUYS:
21781
21782 //guys
21783
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(catchup)
21784 {
21785 box_out("found.");
21786 box_eol();
21787 catchup=false;
21788 }
21789
21790 58 box_out("Reading Custom Guy Data...");
21791
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 ret=readguys(f, &tempheader, keepall&&!get_bit(skip_flags, skip_guys));
21792
1/5
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
58 checkstatus(ret);
21793 58 box_out("okay.");
21794 58 box_eol();
21795 58 break;
21796
21797 case ID_HEROSPRITES:
21798
21799 //player sprites
21800
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(catchup)
21801 {
21802 box_out("found.");
21803 box_eol();
21804 catchup=false;
21805 }
21806
21807 58 box_out("Reading Custom Player Sprite Data...");
21808
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 ret=readherosprites(f, &tempheader, keepall&&!get_bit(skip_flags, skip_herosprites));
21809
1/5
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
58 checkstatus(ret);
21810 58 box_out("okay.");
21811 58 box_eol();
21812 58 break;
21813
21814 case ID_SUBSCREEN:
21815
21816 //custom subscreens
21817
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(catchup)
21818 {
21819 box_out("found.");
21820 box_eol();
21821 catchup=false;
21822 }
21823
21824 58 box_out("Reading Custom Subscreen Data...");
21825
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 ret=readsubscreens(f, &tempheader, keepall&&!get_bit(skip_flags, skip_subscreens));
21826
1/5
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
58 checkstatus(ret);
21827 58 box_out("okay.");
21828 58 box_eol();
21829 58 break;
21830
21831 case ID_FFSCRIPT:
21832
21833 //Freeform combo scripts
21834
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(catchup)
21835 {
21836 box_out("found.");
21837 box_eol();
21838 catchup=false;
21839 }
21840
21841 58 box_out("Reading FF Script Data...");
21842
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 ret=readffscript(f, &tempheader, keepall&&!get_bit(skip_flags, skip_ffscript));
21843
1/5
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
58 checkstatus(ret);
21844 58 box_out("okay.");
21845 58 box_eol();
21846 58 break;
21847
21848 case ID_SFX:
21849
21850 //SFX data
21851
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(catchup)
21852 {
21853 box_out("found.");
21854 box_eol();
21855 catchup=false;
21856 }
21857
21858 58 box_out("Reading SFX Data...");
21859
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 ret=readsfx(f, &tempheader, keepall&&!get_bit(skip_flags, skip_sfx));
21860
1/5
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
58 checkstatus(ret);
21861 58 box_out("okay.");
21862 58 box_eol();
21863 58 break;
21864
21865 case ID_MIDIS:
21866
21867 //midis
21868
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(catchup)
21869 {
21870 box_out("found.");
21871 box_eol();
21872 catchup=false;
21873 }
21874
21875 58 box_out("Reading Tunes...");
21876
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 ret=readtunes(f, &tempheader, tunes, keepall&&!get_bit(skip_flags, skip_midis));
21877
1/5
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
58 checkstatus(ret);
21878 58 box_out("okay.");
21879 58 box_eol();
21880 58 break;
21881
21882 case ID_CHEATS:
21883
21884 //cheat codes
21885
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(catchup)
21886 {
21887 box_out("found.");
21888 box_eol();
21889 catchup=false;
21890 }
21891
21892 58 box_out("Reading Cheat Codes...");
21893
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 ret=readcheatcodes(f, &tempheader, keepall&&!get_bit(skip_flags, skip_cheats));
21894
1/5
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
58 checkstatus(ret);
21895 58 box_out("okay.");
21896 58 box_eol();
21897 58 break;
21898
21899 case ID_ITEMDROPSETS:
21900
21901 //item drop sets
21902
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(catchup)
21903 {
21904 box_out("found.");
21905 box_eol();
21906 catchup=false;
21907 }
21908
21909 58 box_out("Reading Item Drop Sets...");
21910
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 ret=readitemdropsets(f, tempheader.zelda_version, tempheader.build, keepall&&!get_bit(skip_flags, skip_itemdropsets));
21911
1/5
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
58 checkstatus(ret);
21912 58 box_out("okay.");
21913 58 box_eol();
21914 58 break;
21915
21916 case ID_FAVORITES:
21917
21918 //favorite combos and combo aliases
21919
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(catchup)
21920 {
21921 box_out("found.");
21922 box_eol();
21923 catchup=false;
21924 }
21925
21926 58 box_out("Reading Favorite Combos...");
21927
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 ret=readfavorites(f, tempheader.zelda_version, tempheader.build, keepall&&!get_bit(skip_flags, skip_favorites));
21928
1/5
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
58 checkstatus(ret);
21929 58 box_out("okay.");
21930 58 box_eol();
21931 58 break;
21932
21933 default:
21934 if(!catchup)
21935 {
21936 box_out("Bad token! Searching...");
21937 box_eol();
21938 }
21939
21940 catchup=true;
21941 break;
21942 }
21943
21944
21945
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1392 times.
1392 if(catchup)
21946 {
21947 //section id
21948 section_id=(section_id<<8);
21949
21950 if(!p_getc(&tempbyte,f,true))
21951 {
21952 return qe_invalid;
21953 }
21954
21955 section_id+=tempbyte;
21956 }
21957
21958 else
21959 {
21960 //section id
21961
2/2
✓ Branch 0 taken 58 times.
✓ Branch 1 taken 1334 times.
1392 if(!pack_feof(f))
21962 {
21963
1/2
✓ Branch 0 taken 1334 times.
✗ Branch 1 not taken.
1334 if(!p_mgetl(&section_id,f,true))
21964 {
21965 return qe_invalid;
21966 }
21967 1334 }
21968 }
21969 }
21970 58 }
21971 else
21972 {
21973 //rules
21974 box_out("Reading Rules...");
21975 ret=readrules(f, &tempheader, keepall&&!get_bit(skip_flags, skip_rules));
21976 checkstatus(ret);
21977 box_out("okay.");
21978 box_eol();
21979
21980 //strings
21981 box_out("Reading Strings...");
21982 ret=readstrings(f, &tempheader, keepall&&!get_bit(skip_flags, skip_strings));
21983 checkstatus(ret);
21984 box_out("okay.");
21985 box_eol();
21986
21987 //door combo sets
21988 box_out("Reading Doors...");
21989 ret=readdoorcombosets(f, &tempheader, keepall&&!get_bit(skip_flags, skip_doors));
21990 checkstatus(ret);
21991 box_out("okay.");
21992 box_eol();
21993
21994 //dmaps
21995 box_out("Reading DMaps...");
21996 ret=readdmaps(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXDMAPS, keepall&&!get_bit(skip_flags, skip_dmaps));
21997 checkstatus(ret);
21998 box_out("okay.");
21999 box_eol();
22000
22001 // misc data
22002 box_out("Reading Misc. Data...");
22003 ret=readmisc(f, &tempheader, Misc, keepall&&!get_bit(skip_flags, skip_misc));
22004 checkstatus(ret);
22005 box_out("okay.");
22006 box_eol();
22007
22008 //items
22009 box_out("Reading Items...");
22010 ret=readitems(f, tempheader.zelda_version, tempheader.build, keepall&&!get_bit(skip_flags, skip_items));
22011 checkstatus(ret);
22012 box_out("okay.");
22013 box_eol();
22014
22015 //weapons
22016 box_out("Reading Weapons...");
22017 ret=readweapons(f, &tempheader, keepall&&!get_bit(skip_flags, skip_weapons));
22018 checkstatus(ret);
22019 box_out("okay.");
22020 box_eol();
22021
22022 //guys
22023 box_out("Reading Custom Guy Data...");
22024 ret=readguys(f, &tempheader, keepall&&!get_bit(skip_flags, skip_guys));
22025 checkstatus(ret);
22026 box_out("okay.");
22027 box_eol();
22028
22029 //maps
22030 box_out("Reading Maps...");
22031 ret=readmaps(f, &tempheader, keepall&&!get_bit(skip_flags, skip_maps));
22032 mapsread=true;
22033 checkstatus(ret);
22034 box_out("okay.");
22035 box_eol();
22036
22037 //combos
22038 box_out("Reading Combos...");
22039 ret=readcombos(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXCOMBOS, keepall&&!get_bit(skip_flags, skip_combos));
22040 combosread=true;
22041 checkstatus(ret);
22042 box_out("okay.");
22043 box_eol();
22044
22045 //color data
22046 box_out("Reading Color Data...");
22047 ret=readcolordata(f, Misc, tempheader.zelda_version, tempheader.build, 0, newerpdTOTAL, keepall&&!get_bit(skip_flags, skip_csets));
22048 checkstatus(ret);
22049 box_out("okay.");
22050 box_eol();
22051
22052 //tiles
22053 box_out("Reading Tiles...");
22054 ret=readtiles(f, newtilebuf, &tempheader, tempheader.zelda_version, tempheader.build, 0, NEWMAXTILES, false, keepall&&!get_bit(skip_flags, skip_tiles));
22055 checkstatus(ret);
22056 box_out("okay.");
22057 box_eol();
22058
22059 //midis
22060 box_out("Reading Tunes...");
22061 ret=readtunes(f, &tempheader, tunes, keepall&&!get_bit(skip_flags, skip_midis));
22062 checkstatus(ret);
22063 box_out("okay.");
22064 box_eol();
22065
22066 //cheat codes
22067 box_out("Reading Cheat Codes...");
22068 ret=readcheatcodes(f, &tempheader, keepall&&!get_bit(skip_flags, skip_cheats));
22069 checkstatus(ret);
22070 box_out("okay.");
22071 box_eol();
22072
22073 //initialization data
22074 box_out("Reading Init. Data...");
22075 ret=readinitdata(f, &tempheader, keepall&&!get_bit(skip_flags, skip_initdata));
22076 checkstatus(ret);
22077 box_out("okay.");
22078 box_eol();
22079
22080 if(keepall&&!get_bit(skip_flags, skip_subscreens))
22081 {
22082 setupsubscreens();
22083
22084 for(int32_t i=0; i<MAXDMAPS; ++i)
22085 {
22086 int32_t type=DMaps[i].type&dmfTYPE;
22087 DMaps[i].active_subscreen=(type == dmOVERW || type == dmBSOVERW)?0:1;
22088 DMaps[i].passive_subscreen=(get_bit(quest_rules,qr_ENABLEMAGIC))?0:1;
22089 }
22090 }
22091
22092 box_out("Setting Up Default Sound Effects...");
22093
22094 if(keepall&&!get_bit(skip_flags, skip_sfx))
22095 setupsfx();
22096
22097 box_out("okay.");
22098 box_eol();
22099
22100 //player sprites
22101 box_out("Reading Custom Player Sprite Data...");
22102 ret=readherosprites2(f, -1, 0, keepall&&!get_bit(skip_flags, skip_herosprites));
22103 checkstatus(ret);
22104 box_out("okay.");
22105 box_eol();
22106
22107 box_out("Setting Up Default Item Drop Sets...");
22108 ret=readitemdropsets(f, -1, 0, keepall&&!get_bit(skip_flags, skip_itemdropsets));
22109 box_out("okay.");
22110 box_eol();
22111 }
22112
22113 58 init_spritelists();
22114
22115 // check data
22116
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 if(f)
22117 {
22118 58 pack_fclose(f);
22119 58 }
22120
22121
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 if(!oldquest)
22122 {
22123
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(exists(tmpfilename))
22124 {
22125 delete_file(tmpfilename);
22126 }
22127 58 }
22128
22129
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
58 if(fixffcs && combosread && mapsread)
22130 {
22131 for(int32_t i=0; i<map_count; i++)
22132 {
22133 for(int32_t j=0; j<MAPSCRS; j++)
22134 {
22135 for(int32_t m=0; m<32; m++)
22136 {
22137 if(combobuf[TheMaps[(i*MAPSCRS)+j].ffcs[m].getData()].type == cCHANGE)
22138 TheMaps[(i*MAPSCRS)+j].ffcs[m].flags|=ffCHANGER;
22139 }
22140 }
22141 }
22142 }
22143
22144
2/2
✓ Branch 0 taken 45 times.
✓ Branch 1 taken 13 times.
58 if(get_bit(quest_rules, qr_CONTFULL_DEP))
22145 {
22146 13 set_bit(quest_rules, qr_CONTFULL_DEP, 0);
22147 13 set_bit(zinit.misc, idM_CONTPERCENT, 1);
22148 13 zinit.cont_heart=100;
22149 13 zinit.start_heart=zinit.hc;
22150 13 }
22151
22152 58 box_out("Done.");
22153 58 box_eol();
22154 58 box_end(false);
22155
22156 // if (keepall==true||!get_bit(skip_flags, skip_header))
22157
2/4
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 58 times.
58 if(keepall&&!get_bit(skip_flags, skip_header))
22158 {
22159 58 memcpy(Header, &tempheader, sizeof(tempheader));
22160 58 }
22161
2/4
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 58 times.
58 if(keepall&&!get_bit(skip_flags, skip_zinfo))
22162 {
22163 58 ZI.copyFrom(tempzi);
22164 58 }
22165
22166
2/4
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 58 times.
58 if(!keepall||get_bit(skip_flags, skip_maps))
22167 {
22168 map_count=old_map_count;
22169 }
22170
22171
2/4
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 58 times.
58 if(!keepall||get_bit(skip_flags, skip_rules))
22172 {
22173 memcpy(quest_rules, old_quest_rules, QUESTRULES_NEW_SIZE);
22174 memcpy(extra_rules, old_extra_rules, EXTRARULES_SIZE);
22175 }
22176
22177
2/4
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 58 times.
58 if(!keepall||get_bit(skip_flags, skip_midis))
22178 {
22179 memcpy(midi_flags, old_midi_flags, MIDIFLAGS_SIZE);
22180 }
22181
22182
2/4
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 58 times.
✗ Branch 3 not taken.
58 if(deletefilename[0] && exists(deletefilename))
22183 {
22184 58 delete_file(deletefilename);
22185 58 }
22186
22187 //Debug FFCore.quest_format[]
22188 58 al_trace("Quest made in ZC Version: %x\n", FFCore.quest_format[vZelda]);
22189 58 al_trace("Quest made in ZC Build: %d\n", FFCore.quest_format[vBuild]);
22190 58 al_trace("Quest Section 'Header' is Version: %d\n", FFCore.quest_format[vHeader]);
22191 58 al_trace("Quest Section 'Rules' is Version: %d\n", FFCore.quest_format[vRules]);
22192 58 al_trace("Quest Section 'Strings' is Version: %d\n", FFCore.quest_format[vStrings]);
22193 58 al_trace("Quest Section 'Misc' is Version: %d\n", FFCore.quest_format[vMisc]);
22194 58 al_trace("Quest Section 'Tiles' is Version: %d\n", FFCore.quest_format[vTiles]);
22195 58 al_trace("Quest Section 'Combos' is Version: %d\n", FFCore.quest_format[vCombos]);
22196 58 al_trace("Quest Section 'CSets' is Version: %d\n", FFCore.quest_format[vCSets]);
22197 58 al_trace("Quest Section 'Maps' is Version: %d\n", FFCore.quest_format[vMaps]);
22198 58 al_trace("Quest Section 'DMaps' is Version: %d\n", FFCore.quest_format[vDMaps]);
22199 58 al_trace("Quest Section 'Doors' is Version: %d\n", FFCore.quest_format[vDoors]);
22200 58 al_trace("Quest Section 'Items' is Version: %d\n", FFCore.quest_format[vItems]);
22201 58 al_trace("Quest Section 'Weapons' is Version: %d\n", FFCore.quest_format[vWeaponSprites]);
22202 58 al_trace("Quest Section 'Colors' is Version: %d\n", FFCore.quest_format[vColours]);
22203 58 al_trace("Quest Section 'Icons' is Version: %d\n", FFCore.quest_format[vIcons]);
22204 //al_trace("Quest Section 'Gfx Pack' is Version: %d; qst.cpp doesn't read this!\n", FFCore.quest_format[vGfxPack]);
22205 58 al_trace("Quest Section 'InitData' is Version: %d\n", FFCore.quest_format[vInitData]);
22206 58 al_trace("Quest Section 'Guys' is Version: %d\n", FFCore.quest_format[vGuys]);
22207 58 al_trace("Quest Section 'MIDIs' is Version: %d\n", FFCore.quest_format[vMIDIs]);
22208 58 al_trace("Quest Section 'Cheats' is Version: %d\n", FFCore.quest_format[vCheats]);
22209 //al_trace("Quest Section 'Save Format' is Version: %d; qst.cpp doesn't read this!\n", FFCore.quest_format[vSaveformat]);
22210 58 al_trace("Quest Section 'Combo Aliases' is Version: %d\n", FFCore.quest_format[vComboAliases]);
22211 58 al_trace("Quest Section 'Player Sprites' is Version: %d\n", FFCore.quest_format[vHeroSprites]);
22212 58 al_trace("Quest Section 'Subscreen' is Version: %d\n", FFCore.quest_format[vSubscreen]);
22213 58 al_trace("Quest Section 'Dropsets' is Version: %d\n", FFCore.quest_format[vItemDropsets]);
22214 58 al_trace("Quest Section 'FFScript' is Version: %d\n", FFCore.quest_format[vFFScript]);
22215 58 al_trace("Quest Section 'SFX' is Version: %d\n", FFCore.quest_format[vSFX]);
22216 58 al_trace("Quest Section 'Favorites' is Version: %d\n", FFCore.quest_format[vFavourites]);
22217 58 al_trace("Quest Section 'CompatRules' is Version: %d\n", FFCore.quest_format[vCompatRule]);
22218 //Print metadata for versions under 2.10 here. Bleah.
22219
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if( FFCore.quest_format[vZelda] < 0x210 )
22220 {
22221 zprint2("\n[ZQUEST CREATOR METADATA]\n");
22222
22223 switch(FFCore.quest_format[vZelda])
22224 {
22225 case 0x193:
22226 {
22227 zprint2("Last saved in ZC Editor Version: 1.93, Beta %d\n", FFCore.quest_format[vBuild]); break;
22228 }
22229 case 0x192:
22230 {
22231 zprint2("Last saved in ZC Editor Version: 1.92, Beta %d\n", FFCore.quest_format[vBuild]); break;
22232 }
22233 case 0x190:
22234 {
22235 zprint2("Last saved in ZC Editor Version: 1.90");
22236 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22237 else zprint2("\n");
22238 break;
22239 }
22240 case 0x188:
22241 {
22242 zprint2("Last saved in ZC Editor Version: 1.88");
22243 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22244 else zprint2("\n");
22245 break;
22246 }
22247 case 0x187:
22248 {
22249 zprint2("Last saved in ZC Editor Version: 1.87");
22250 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22251 else zprint2("\n");
22252 break;
22253 }
22254 case 0x186:
22255 {
22256 zprint2("Last saved in ZC Editor Version: 1.86");
22257 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22258 else zprint2("\n");
22259 break;
22260 }
22261 case 0x185:
22262 {
22263 zprint2("Last saved in ZC Editor Version: 1.85");
22264 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22265 else zprint2("\n");
22266 break;
22267 }
22268 case 0x184:
22269 {
22270 zprint2("Last saved in ZC Editor Version: 1.84");
22271 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22272 else zprint2("\n");
22273 break;
22274 }
22275 case 0x183:
22276 {
22277 zprint2("Last saved in ZC Editor Version: 1.83");
22278 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22279 else zprint2("\n");
22280 break;
22281 }
22282 case 0x182:
22283 {
22284 zprint2("Last saved in ZC Editor Version: 1.82");
22285 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22286 else zprint2("\n");
22287 break;
22288 }
22289 case 0x181:
22290 {
22291 zprint2("Last saved in ZC Editor Version: 1.81");
22292 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22293 else zprint2("\n");
22294 break;
22295 }
22296 case 0x180:
22297 {
22298 zprint2("Last saved in ZC Editor Version: 1.80");
22299 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22300 else zprint2("\n");
22301 break;
22302 }
22303 default:
22304 {
22305 zprint2("Last saved in ZC Editor Version: %x, Beta %d\n", FFCore.quest_format[vZelda],FFCore.quest_format[vBuild]); break;
22306 }
22307 }
22308 }
22309
22310 58 return qe_OK;
22311
22312 invalid:
22313 box_out("error.");
22314 box_eol();
22315 box_end(true);
22316
22317 if(f)
22318 {
22319 pack_fclose(f);
22320 }
22321
22322 if(!oldquest)
22323 {
22324 if(exists(tmpfilename))
22325 {
22326 delete_file(tmpfilename);
22327 }
22328
22329 if(deletefilename[0] && exists(deletefilename))
22330 {
22331 delete_file(deletefilename);
22332 }
22333 }
22334
22335 return qe_invalid;
22336
22337 58 }
22338
22339 58 int32_t loadquest(const char *filename, zquestheader *Header, miscQdata *Misc, zctune *tunes, bool show_progress, bool compressed, bool encrypted, bool keepall, byte *skip_flags, byte printmetadata, bool report, byte qst_num)
22340 {
22341 58 loading_qst_name = filename;
22342 58 loading_qst_num = qst_num;
22343 58 loadquest_report = report;
22344 58 int32_t ret = _lq_int(filename, Header, Misc, tunes, show_progress, compressed, encrypted, keepall, skip_flags,printmetadata);
22345 58 load_tmp_zi = NULL;
22346 58 loading_qst_name = NULL;
22347 58 loadquest_report = false;
22348 58 loading_qst_num = 0;
22349 58 return ret;
22350 }
22351 /*** end of qst.cc ***/
22352
22353